Skip to content

Instantly share code, notes, and snippets.

@rcombs
Last active June 17, 2017 17:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rcombs/dd041d75357107ef7e2b26ba077a9612 to your computer and use it in GitHub Desktop.
Save rcombs/dd041d75357107ef7e2b26ba077a9612 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Fix Twitter
// @namespace https://gist.github.com/rcombs/
// @version 0.1
// @description stop Twitter from being a piece of ѕһіt
// @author Rodger Combs
// @match https://twitter.com/*
// @grant GM_addStyle
// @downloadURL https://gist.github.com/rcombs/dd041d75357107ef7e2b26ba077a9612/raw/fix-twitter.user.js
// ==/UserScript==
(function() {
'use strict';
/* jshint ignore:start */
var CSSText = (<><![CDATA[
.avatar {
border-radius: 5px !important;
}
.DashboardProfileCard-avatarImage, .ProfileCard-avatarImage {
border-radius: 7px !important;
}
.size32 {
border-radius: 4px !important;
}
div.RichEditor {
border-radius: 3px !important;
}
.RichEditor div[contenteditable], .RichEditor div[contenteditable]:focus, .RichEditor div[contenteditable].fake-focus {
padding: 8px !important;
}
]]></>).toString();
/* jshint ignore:end */
GM_addStyle(CSSText);
var subs = {
'shit': 'ѕһіt',
'SHIT': '𝖲𝖧𝖨𝖳',
'fuck': 'fυсk',
'FUCK': '𝖥𝖴𝖢𝖪',
'asshole': 'aѕѕһοIе',
'ASSHOLE': '𝖠𝖲𝖲𝖧𝖮𝖫𝖤',
};
function doFixup(el) {
for (var sub in subs) {
el.nodeValue = el.nodeValue.replace(new RegExp(sub, 'g'), subs[sub]);
}
}
function recursivelyFixup(el) {
if (el.nodeName == '#text')
doFixup(el);
for (var i = 0; i < el.childNodes.length; i++)
recursivelyFixup(el.childNodes[i]);
}
document.body.addEventListener('blur', function (e) {
if (e && e.target && e.target.isContentEditable) {
console.error(e.target);
recursivelyFixup(e.target);
}
}, true);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment