Created
May 22, 2016 16:31
-
-
Save anonymous/6993b7c4b379b06613705e8dd503e7c4 to your computer and use it in GitHub Desktop.
This file contains 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 4chan Ø | |
// @namespace 4chan-ø | |
// @version 1.3 | |
// @grant none | |
// @match https*://boards.4chan.org/* | |
// @include https*://boards.4chan.org/* | |
// ==/UserScript== | |
var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1; | |
window.onload = function() { | |
window.onkeyup = function(e) { | |
if (e.target.tagName.toLowerCase() === 'textarea') { | |
if (isFirefox) { | |
if (e.key.toLowerCase() !== 'ø') { | |
return; | |
} | |
} else { | |
if (e.keyCode !== 186 && e.keyCode !== 192) { | |
return; | |
} | |
} | |
var elem = e.target; | |
var pos = elem.selectionStart; | |
elem.value = elem.value | |
.replace(/Ø/g, 'Ǿ') | |
.replace(/ø/g, 'ǿ'); | |
elem.setSelectionRange(pos, pos); | |
} | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment