Created
August 14, 2019 19:54
-
-
Save fdebijl/7026dbd4f61de558b6aa2ebd9ac81be5 to your computer and use it in GitHub Desktop.
Ik ben geen expert, maar...
This file contains hidden or 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 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