Last active
October 17, 2019 13:21
-
-
Save IsaMorphic/0febe5c59931b7bbec4403dd2c58fb04 to your computer and use it in GitHub Desktop.
Wordfrick is a tampermonkey script that jumbles up the text on any webpage of your choice. The results are oftentimes hilarious.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Wordfrick | |
// @namespace https://www.chosenfewsoftware.com | |
// @version 1.0 | |
// @description Screw up any text on any webpage with the click of your mouse | |
// @author Yodadude2003 | |
// @match *://*/* | |
// @grant none | |
// @require https://code.jquery.com/jquery-3.4.1.min.js | |
// ==/UserScript== | |
setInterval(function() { | |
'use strict'; | |
// Your code here... | |
let stopWords = ["for", "and", "nor", "but", "or", "yet", "so", "as", "with", "not", "to", "of", "on", "in", "all", "a", "an", "is", "by", "the"]; | |
let punctuation = [".", ",", ";", "!", "?", "\"", "(", ")", "[", "]", ":"]; | |
let numbers = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]; | |
let tagTypes = ["p", "span", "a", "li", "em", "strong"]; | |
$(tagTypes.join(":not([fricked]),")) | |
.contents() | |
.filter(function() { | |
return this.nodeType == Node.TEXT_NODE; | |
}) | |
.each(function() { | |
let tokens = this.data.split(" "); | |
let startIdx = Math.floor(Math.random() * 5); | |
for(let i = 0; i < tokens.length; i++) | |
{ | |
let otherIdx = Math.floor(Math.random() * tokens.length); | |
let thisWord = tokens[i]; | |
let otherWord = tokens[otherIdx]; | |
let areEmpty = thisWord == "" || otherWord == ""; | |
let areStopWords = stopWords.includes(thisWord.toLowerCase()) || stopWords.includes(otherWord.toLowerCase()); | |
let areProperWords = thisWord != thisWord.toLowerCase() || otherWord != otherWord.toLowerCase(); | |
let havePunctuation = punctuation.some(ch => thisWord.includes(ch)) || punctuation.some(ch => otherWord.includes(ch)); | |
let haveNumbers = numbers.some(ch => thisWord.includes(ch)) || numbers.some(ch => otherWord.includes(ch)); | |
if(i > startIdx && !areEmpty && | |
!areStopWords && !areProperWords && | |
!havePunctuation && !haveNumbers) { | |
tokens[i] = otherWord; | |
tokens[otherIdx] = thisWord; | |
} | |
} | |
this.data = tokens.join(" "); | |
}); | |
$(tagTypes.join(":not([fricked]),")).attr("fricked", "true"); | |
}, 500)(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment