Last active
June 17, 2017 17:45
-
-
Save rcombs/dd041d75357107ef7e2b26ba077a9612 to your computer and use it in GitHub Desktop.
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 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