Skip to content

Instantly share code, notes, and snippets.

@hikari-no-yume
Created March 7, 2015 19:50
Show Gist options
  • Save hikari-no-yume/358ae78a9961e6abad57 to your computer and use it in GitHub Desktop.
Save hikari-no-yume/358ae78a9961e6abad57 to your computer and use it in GitHub Desktop.
FEMINIZER X9001 (the 1 is significant)
function misandry() {
var replaceables = Object.keys(reptable)
/* sort by length descending, value ascending
this is to ensure greedy matching */
.sort((s1, s2) => {
const lengthOrder = s2.length - s1.length;
const valueOrder = (s1 === s2) ? 0 : (s1 < s2) ? -1 : 1;
return lengthOrder ? lengthOrder : valueOrder;
}),
ueberRegex = new RegExp('\\b(' + replaceables.join('|') + ')\\b', 'gm'),
evilXML = document.getElementById('sexist').innerHTML;
/* find successive matches */
var match;
while ((match = ueberRegex.exec(evilXML)) !== null) {
/* substitute! */
evilXML = evilXML.substr(0, match.index)
+ reptable[match[0]]
+ evilXML.substr(match.index + match[0].length);
}
/* crush the patriarchy! */
document.getElementById('sexist').innerHTML = evilXML;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment