Scrambler

scrambles all the text on a page

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         Scrambler
// @namespace    https://greasyfork.org/en/scripts/22121-scrambler
// @version      1.1
// @description  scrambles all the text on a page
// @author       abbott
// @match        *://*/*
// ==/UserScript==

window.onload = function() {
  var elements = document.body.getElementsByTagName('*');

  for (var i = 0; i < elements.length; i++) {
    var text = '';
    elements[i].innerHTML.split(/(<.+?>)/).forEach(function(s) {
      text += s.charAt(0) === '<' ? s : scramble(s);
    });

    elements[i].innerHTML = text;
  }
};

// scrambles middle letters 
function scramble(s) {
  if (s.includes('&nbsp;')) { // ignores nbsp messes up the scramble a bunch
    return s;
  }

  return s.split(' ').map(function(word) {
    if (word.length > 3) {
      var chars = word.split('');

      for (var i = 1; i < chars.length - 1; i++) {
        var j = Math.floor(Math.random() * (i - 1) + 1);
        var temp = chars[i];
        chars[i] = chars[j];
        chars[j] = temp;
      }

      return chars.join('');
    }

    return word;
  }).join(' ');
}