Even though my short brush with Internet fame appears to be over (Detrumpify has about 920 users today, up only 30 from yesterday), pride required that I update the extension because it was a bit too quick-n-dirty for my taste. Everything in it was hard-coded and that meant that every update I made to add new sites or insults would require users to approve an update. Hard-coding stuff in your programs is a big no-no, starting from CS 101 on.
So, I have a rewritten version available, and intrepid fans can help me out by testing it. You will not find it by searching on the Chrome Web Store, instead, get it directly from here. It is substantially more complicated under the hood than before, so expect bugs. (Github here, in “v2” folder.)
An important difference between this and the classic version is that there is an options page. It looks like this:
The main thing it lets you do is specify an URL from which a configuration file will periodically be downloaded. The config file contains the actual insults as well as some other parameters. I will host and maintain several configuration files ToolsOfOurTools, but anyone who wants to make one (for example, to mock a different presidential candidate) will be able to do so and just point to it.
If you want to make changes locally, you can also load a file, click on the edit button, make changes, and then click on the lock button. From then on the extension will use your custom changes.
The format of the config file is simple. Here’s an example with most of the names removed:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
{ "actions": { "trump": { "find_regex": [ "(Donald\\s*(J\\.?\\s*)?)?Trump", "g" ], "monikers": [ "Cheeto Jesus", "Bone-in Ham" ], "randomize_mode": "always", "bracket": ["“","”"], } }, "refresh_age": 604800000, "run_info": { "count": 5, "maxTimeout": 12000, "startTimeout": 1000, "timeMultiplier": 1.8 }, "schema": "InsultMarkupLanguage/0.1", "whitelist": [ "www.cnn.com", "nytimes.com" ] } |
Explanation:
-
actions is a container that will hold one or more named sets of search and replace instructions. This file just has one for replacing trump variations, but one can make files that will replace many different things according to different rules
-
find_regex inside the trump action finds a few variations of Trump, Donald Trump, Donald J. Trump.
-
monikers section lists the alternatives.
-
randomize_mode can be
always ,
hourly ,
daily , and tells how often the insult changes. In
always , it will change with each appearance in the document.
-
refresh_age is how long to wait (in milliseconds) before hitting the server for an update.
-
run_info tells how long to wait before running the plugin and how many times to run. This is for sites that do not elaborate their content until after some javascript runs. (ie, every site these days, apparently). Here, it runs after 1000ms, then runs four more times, each time waiting 1.8x as long as the last time.
-
bracket can be set to a two-element array of text to be placed before and after any trump replacement.
-
schema is required to ID the format of this file and should look just like that.
-
whitelist is a list of sites that are enabled to run the extension. Et voila.
Let me know if you experience issues / bugs! The code that runs this is quite a bit more complex than the version you’re running now. In particular, I’m still struggling a bit with certain websites that turn on “content security policies” that get in the way of the config fetch. Sometimes it works, sometimes it doesn’t.