Tagged: greasemonkey

Dear Diary Maker for CNN’s Jim @Acosta Twitter page – A GreaseMonkey Javascript script

Recently, “conservatives” in the US started a campaign to troll CNN’s Jim Acosta for his repeated interruptions of US president Donald Trump. They did this by re-posting his Twitter messages prefixed with the words “Dear Diary.” Trump, himself, followed this advice and famously “Dear Diary”‘d Jim Acosta’s report from the Mexican border.

I have created this GreaseMonkey script, which automatically prefixes his tweets with the words “Dear Diary,” making it easy to screenshot them and post online.

// ==UserScript==
// @name        Dear Diary Maker for Acosta on Twitter
// @namespace   net.moralvolcano.js.dear_diary_acosta_twitter
// @include     https://twitter.com/acosta/*
// @include     https://twitter.com/Acosta
// @version     1
// @grant       none
// ==/UserScript==

function handle_DOMLoaded() {
	try {
		window.setTimeout(
			function() {
				changeAcostaTweets();
			}, 
			6*1000);
	} catch (e) {
		console.error("DDMFAT Error: " + e);
	}
}


document.addEventListener("DOMContentLoaded", handle_DOMLoaded, false);

function changeAcostaTweets() {
	console.error("DDMFAT Error: Loaded");
	var arTags = document.getElementsByTagName("p");
	for (var i = 0; i < arTags.length; i++) {
		if (arTags[i].className.indexOf("tweet-text") > 0) {
			arTags[i].innerHTML = "<marquee direction=\"down\" loop=\"1\" behavior=\"alternate\" style=\"height: 2em; width: 100%; \">Dear Diary,</marquee><br /><br /><blockquote style=\"margin-left: 3em;\">" + arTags[i].innerHTML + "</blockquote>";
			if (location.href.indexOf("/status/") > "https://twitter.com".length) {
				break; // ignore comments
			}
		}
	}
	var arDivs = document.getElementsByTagName("div");
	for (var i = 0; i < arDivs.length; i++) {
		if (arDivs[i].className.indexOf("tweet-stats-container") > 0) {
			arDivs[i].parentNode.removeChild(arDivs[i]);
			break;
		}
	}
}

The code is also available at
https://pastebin.com/drT8RjSx
in case WordPress warbles the code.