Skip to content

Instantly share code, notes, and snippets.

@fdebijl
Created August 14, 2019 19:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fdebijl/7026dbd4f61de558b6aa2ebd9ac81be5 to your computer and use it in GitHub Desktop.
Save fdebijl/7026dbd4f61de558b6aa2ebd9ac81be5 to your computer and use it in GitHub Desktop.
Ik ben geen expert, maar...
// ==UserScript==
// @name Ik ben geen expert, maar...
// @namespace https://floris.debijl.xyz/
// @version 1.0
// @author @Fdebijl
// @license GNU Affero General Public License 3.0 https://www.gnu.org/licenses/agpl-3.0.nl.html
// @match https://twitter.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
const tweetTextSelector = `div.css-1dbjc4n.r-18u37iz.r-thb0q2 > div.css-1dbjc4n.r-1iusvr4.r-46vdb2.r-1777fci.r-5f2r5o.r-bcqeeo.r-1mi0q7o > div.css-901oao.r-jwli3a.r-1qd0xha.r-a023e6.r-16dba41.r-ad9z0x.r-bcqeeo.r-bnwqim.r-qvutc0 > span`;
const experts = {
en: `I'm not an expert, but `,
nl: `Ik ben geen expert, maar `
}
const decapitalize = (string) => {
return string.charAt(0).toLowerCase() + string.slice(1);
}
setInterval(() => {
[...document.querySelectorAll(tweetTextSelector)].forEach(tweet => {
if (!tweet.innerText) return;
if (tweet.attributes.prefixed) return;
const prefix = experts[tweet.parentElement.attributes.lang.value] || experts.en;
tweet.innerText = prefix + decapitalize(tweet.innerText);
tweet.setAttribute('prefixed', true);
});
}, 5000);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment