Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vocabulistics enhancemaments #36

Open
wants to merge 31 commits into
base: gh-pages
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
0fda99e
work from a dictionary of phrases instead of hardcoded strings
jstange Jul 4, 2016
a8de3e5
audience suggested additional phrases
jstange Jul 4, 2016
3b59583
it's spelled 'bloviating'
jstange Jul 5, 2016
4b59188
further juvenile insults; some fiddling for Chrome store
jstange Sep 27, 2016
6c8792a
further tuning of english grammar
jstange Sep 28, 2016
f9aefa8
Firefox manifest tweaks
jstange Sep 28, 2016
93a840c
Lord Dampnut
jstange Feb 2, 2017
1e0158c
Cheez-It Ceaușescu
jstange Feb 2, 2017
9557a7b
pressing on towards 2.4
jstange Feb 6, 2017
1e4159e
2.4 polish (released)
jstange Feb 7, 2017
edb26f8
Easy D, etc
jstange Feb 12, 2017
6ea8294
initial ActionStations melding
jstange Feb 20, 2017
59c3fce
more widget works
jstange Feb 21, 2017
b411251
hide/show toggle properly cooperating with tcycle
jstange Feb 23, 2017
46854fa
options page and themes for ActionStations
jstange Feb 23, 2017
d9d1def
render actionstations widget correctly after invalidating cache
jstange Feb 23, 2017
ad11a15
fully integrated options page, all bells and whistles working
jstange Feb 24, 2017
b618232
prevent facebook from stomping text colors
jstange Feb 24, 2017
58b7845
drop a rogue console.log
jstange Feb 24, 2017
d4b236d
the poster child for hyper-paranoid manatees with chronic gout
jstange Feb 24, 2017
4e92d44
jquery-ui draggable
jstange Feb 24, 2017
aba0812
ActionStations integration first release; more Bannon-isms
jstange Mar 3, 2017
dda2669
new Bannon-isms, minor ActionStations tweaks
jstange Mar 5, 2017
ad2d6b3
ActionStations draggable handle improvements
jstange Mar 5, 2017
9b1f4cc
improved grammar handling and ActionStations bundle
jstange Mar 15, 2017
248edef
grammatical and syntactical twiddles
jstange Mar 16, 2017
f4076b2
pull phrases from endpoint; preliminary update to Firefox
jstange Apr 4, 2017
73bf848
fresh screens; templating for content_scripts
jstange Apr 5, 2017
b4b7b38
massive overhaul of Action Stations; convert Firefox plugin to WebExt…
jstange May 29, 2017
1758ab4
work around Mozilla's punk-ass validator
jstange May 29, 2017
a42d975
fix some grammar around Bannon; drop ActionStations, nobody uses it
jstange Jan 17, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
_site/
.sass-cache/
.*.swp
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@ The best way to install this is from [the chrome webstore](https://chrome.google
### Firefox

Install it from [Mozilla's add-on site](https://addons.mozilla.org/en-US/firefox/addon/some-rich-asshole/)

### Insults I didn't make up myself or find on the public internet
Mark Krawczyk - "stale dorito"
Emily Todd - "tantrum pumpkin"
14 changes: 14 additions & 0 deletions chrome.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
$(document).ready(function() {

<%= content_script %>

if(window.location.hostname != "wtfisastevebannon.com" && !window.location.href.match(/twitter\.com\/SteveBannonFcts/i)){
walk(document.body);

new MutationObserver(function() {
walk(document.body);
}).observe(document.body, {
childList: true
});
}
});
241 changes: 241 additions & 0 deletions chrome/content_script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,241 @@
$(document).ready(function() {

var trumpedPhrases = []
var bannonedPhrases = []
var bannon_no_possessive = new RegExp("bannon(?!['’]s)", "i");
var fullname = "\\b((?:steve|steven|stephen)\\s*(?:k\\.?)?\\s*bannon)";
var bannon_full = new RegExp(fullname, "i");
var bannon_full_punct = new RegExp(fullname+"\\s?(?:[.,?\\-!\":(]|$)", "i");
var bannon_last_punct = new RegExp("(bannon)\\s?([.,?\\-!\":(]|$)", "i");
var bannon_full_space = new RegExp(fullname+"\\s", "i");
var bannon_last_space = new RegExp("(bannon)\\s", "i");

function walk(node)
{
var child, next;

switch ( node.nodeType )
{
case 1: // Element
case 9: // Document
case 11: // Document fragment
if(node.tagName != "INPUT"){ // don't futz form inputs
child = node.firstChild;
while ( child )
{
next = child.nextSibling;
walk(child);
child = next;
}
}
break;

case 3: // Text node
handleText(node);
break;
}
}

var foundtrumps = 0;
var foundbannons = 0;
var phrase = "";
var mode = "";
var insertCalls = 0;

function replacer(match, p1, offset, string)
{
realprefix = "";
realname = "";
if(mode == "theDevilHimself"){
if(match == "trump"){
return("trump");
}
if(p1 && p1.length > 0){
realprefix = p1;
} else if(PHRASES["trumpisms_prefixable"].includes(phrase)){
realprefix = "The";
}
realprefix = realprefix + " ";
} else if(mode == "theDevilHimselfPostfix"){
realprefix = phrase;
phrase = p1;
} else {
string = offset;
offset = p1;
}

if(match.match(/[A-Z]/) && !match.match(/[a-z]/)){
phrase = phrase.toUpperCase();
realprefix = realprefix.toUpperCase();
} else if(match.match(/[a-z]/) && !match.match(/[A-Z]/)){
phrase = phrase.toLowerCase();
realprefix = realprefix.toLowerCase();
}

return(realprefix + phrase);
}
// This is a grotesque way of coping with a variable number of backreferences,
// but that's Javascript for you.
function replacer2(match, p1, p2, offset, string)
{
realprefix = "";
realname = "";
if(mode == "theDevilHimself"){
realprefix = phrase
}

if(match.match(/[A-Z]/) && !match.match(/[a-z]/)){
realprefix = realprefix.toUpperCase();
} else if(match.match(/[a-z]/) && !match.match(/[A-Z]/)){
realprefix = realprefix.toLowerCase();
}

return(realprefix + " " + p2);
}

function trumpCrotchDumplings(textNode)
{
var v = textNode.nodeValue;
mode = "trumpCrotchDumplings";

var allphrases = PHRASES["trumpisms_prefixable"].concat(PHRASES["trumpisms_nonprefixable"]);
trumpphrase = allphrases[Math.floor(Math.random()*allphrases.length)];
prefixed_trumpphrase = trumpphrase;
if(PHRASES["trumpisms_prefixable"].includes(trumpphrase)){
prefixed_trumpphrase = "The "+trumpphrase;
}

// The family get simpler patterns
phrase = "Eric (the Beavis-y one), Son of "+prefixed_trumpphrase;
v = v.replace(/(?:Eric )(?:(?:Frederick|F|F\.) )?Trump/i, replacer);
phrase = "Donald Jr (the Butthead-y one), Son of "+prefixed_trumpphrase;
v = v.replace(/(?:(?:Donald|Don) )(?:(?:John|J|J\.) )?Trump,? Jr\.?/i, replacer);
phrase = "Ivanka \"Complicit\" Trump";
v = v.replace(/Ivanka Trump/i, replacer);
phrase = "Tiffany, Daughter of "+prefixed_trumpphrase;
v = v.replace(/Tiffany Trump/i, replacer);

phrase = "First Trophy Wife of "+prefixed_trumpphrase;
v = v.replace(/Ivana Trump/i, replacer);
phrase = "Second Trophy Wife of "+prefixed_trumpphrase;
v = v.replace(/Marla Maples/i, replacer);
phrase = "Third Trophy Wife of "+prefixed_trumpphrase;
v = v.replace(/Melania Trump/i, replacer);


if(textNode.nodeValue != v){
trumpedPhrases.push(v);
foundtrumps++;
textNode.nodeValue = v;
}

}

function theDevilHimself(textNode)
{
var v = textNode.nodeValue;
// var prefixes = ["some", "a", "the"];

var allphrases = PHRASES["trumpisms_prefixable"].concat(PHRASES["trumpisms_nonprefixable"]);
mode = "theDevilHimself";
if(v.match(/trump/i)){
// if his title and full name are present, swap the title with a
// prefixable phrase, so you get things like "Ludicrous Tangerine Ballbag
// Donald Trump signed an Executive Order..."
phrase = PHRASES["trumpisms_prefixable"][Math.floor(Math.random()*PHRASES["trumpisms_prefixable"].length)];
v = v.replace(/(mr\.|the|a|some|president|presidential candidate|candidate|president-elect)\s*((?:donald\s*)(?:(?:john|j|j\.)\s*)?\btrump)\b/gi, replacer2);

phrase = allphrases[Math.floor(Math.random()*allphrases.length)];
// If it's his title and last name, sub name with something that makes
// grammatical sense alongside "the"
if(textNode.nodeValue == v && trumpedPhrases.indexOf(v) < 0){
v = v.replace(/\b(the [a-z]+ |pro-|anti-|mr\.|the|a|some|president|presidential candidate|candidate|president-elect)\s*(?:donald\s*)?(?:(?:john|j|j\.)\s*)?\btrump\b/gi, replacer);
}

// Show some hate for Trump Tower
mode = "theDevilHimselfPostfix";
if(textNode.nodeValue == v && trumpedPhrases.indexOf(v) < 0){
v = v.replace(/\btrump(\s*tower)\b/gi, replacer);
}

// if it's just his name, swap that
mode = "theDevilHimself";
if(textNode.nodeValue == v && trumpedPhrases.indexOf(v) < 0){
v = v.replace(/\b(?:donald\s*)?(?:(?:john|j|j\.)\s*)?\btrump\b/gi, replacer);
}

if(textNode.nodeValue != v) {
trumpedPhrases.push(v);
}
}

if(textNode.nodeValue != v){
foundtrumps++;
textNode.nodeValue = v
}
}

function svengali(textNode)
{
var v = textNode.nodeValue;
mode = "svengali";
// try to skip things that look like code
if(v.match(/};/) && v.match(/\bvar /)){
return;
}

if(PHRASES["bannonisms"].length > 0){
var bannonphrase = PHRASES["bannonisms"][Math.floor(Math.random()*PHRASES["bannonisms"].length)];
if(bannonphrase.match(/^(was|has|does)/)){
bannonphrase = "who "+bannonphrase;
} else if(!bannonphrase.match(/^(who|the)/)){
bannonphrase = "who is "+bannonphrase;
}
var prebannon = v;
if(bannonedPhrases.indexOf(prebannon) < 0){
if(v.match(bannon_no_possessive)){
if(v.match(bannon_full_punct)){
v = v.replace(bannon_full, "$1, "+bannonphrase);
foundbannons++;
} else if(v.match(bannon_full_space)){
v = v.replace(bannon_full, "$1- "+bannonphrase+"- ");
foundbannons++;
} else if(foundtrumps > 0 || foundbannons > 0) {
if(v.match(bannon_last_punct)){
v = v.replace(bannon_last_punct, "$1, "+bannonphrase+"$2");
} else if(v.match(bannon_last_space)){
v = v.replace(bannon_last_space, "$1- "+bannonphrase+"- ");
}
} else {
console.log("UNCAUGHT MATCH OF STEVE BANNON: "+v);
}
// } else if(v.match(/bannon/i)) { // XXX eh, just skip it
// console.log("FOUND A BANNON WITH APOSTROPHE-S: "+v);
}
if(v != prebannon){
PHRASES["bannonisms"].splice(PHRASES["bannonisms"].indexOf(bannonphrase), 1);
textNode.nodeValue = v;
bannonedPhrases.push(v);
}
}
}
}

function handleText(textNode)
{
trumpCrotchDumplings(textNode);
theDevilHimself(textNode);
svengali(textNode);
}


if(window.location.hostname != "wtfisastevebannon.com" && !window.location.href.match(/twitter\.com\/SteveBannonFcts/i)){
walk(document.body);

new MutationObserver(function() {
walk(document.body);
}).observe(document.body, {
childList: true
});
}
});
Binary file added chrome/icon128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions chrome/jquery-3.1.1.min.js

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions chrome/jquery-ui/jquery-ui.min.js

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions chrome/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"manifest_version": 2,
"name": "Some Rich Asshole Enhanced",
"version": "3.2.2",
"description": "Replaces He-Who-Must-Not-Be-Named's name, and those of some related individuals, with more colorful descriptors.",
"permissions": [
"storage"
],
"content_scripts":
[
{
"matches": ["*://*/*"],
"js": ["jquery-3.1.1.min.js", "jquery-ui/jquery-ui.min.js", "phrases.js", "content_script.js"],
"run_at": "document_end"
}
],
"icons": {
"128": "icon128.png"
}
}
1 change: 1 addition & 0 deletions chrome/phrases.js

Large diffs are not rendered by default.

Loading