Rot1 to punish readers using an ad blocker

Trying to breaking the doomscrolling cycle, I figured I'd read something not about COVID, BLM, or the atrocities our government is committing in response to those (kind of like what you're doing right now?).

Here's a screen shot from a Denver Post article I was trying to read:

Obfuscated news article content

I was just as confused as you are. That is some bizarre text. I first noticed it when I accidentally turned on reader-mode in Safari with an ad blocker on. Turns out if you remove the "you're a monster because you're blocking ads pop-up" then you see the article text blurred out and with rot-1 (as opposed to rot-13) applied to it. Then I completely lost interest in the article content and wanted to see the code doing this obfuscation.

It took a while, but after noticing the elements in question had a blurry-text class, I eventually discovered a blurContent method in some minified JS from a CDN. Here are the relevant functions:

encryptText = function(t) {  
  if (t) {
    for (var e = 0; e < t.length; e++) {
      t = t.replaceAt(e, getNextLetter(t[e]))
  return t
getNextLetter = function(t) {  
  return t.replace(/([a-zA-Z])[^a-zA-Z]*$/, function(t) {
    var e = t.charCodeAt(0)
    switch (e) {
      case 90:
        return "A"
      case 122:
        return "a"
        return String.fromCharCode(++e)

Source but who knows how long that will live.

I didn't dig deep enough to put every piece together to see where and how encryptText is called, but that and getNextLetter is where the magic happens. The latter includes special handling to return the appropriate 'a' so that you don't get a { or a [ back when you pass in a 'z' or 'Z', respectively.

Finally, replaceAt is tacked on to String earlier in the code via:

String.prototype.replaceAt = function (t,e){  
  return this.substr(0,t)+e+this.substr(t+e.length)

I'm not crazy about looping over the input string and overwriting it on each iteration but that's probably not the end of the world. In these absurd and depressing times, this was a welcome distraction.