NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name Autism Removal // @namespace // @description Removes autism on 2007scape reddit // @include http://www.reddit.com/r/2007scape/*/*/*/ // @version 0.1 // ==/UserScript== (function () { 'use strict'; var words = { /////////////////////////////////////////////////////// // Syntax: 'Search word' : 'Replace word', 'splashing' : 'my autism', 'afk guthans' : 'having a social life', 'afk nmz' : 'gaining exp smartly', 'afk training' : 'people that have a social life', 'abuse' : 'smartly use', 'dank' : 'autistic', 'splasher' : 'smart player', /////////////////////////////////////////////////////// '':''}; var regexs = [], replacements = [], tagsWhitelist = ['PRE', 'BLOCKQUOTE', 'CODE', 'INPUT', 'BUTTON', 'TEXTAREA'], rIsRegexp = /^\/(.+)\/([gim]+)?$/, word, text, texts, i, userRegexp; function prepareRegex(string) { return string.replace(/([\[\]\^\&\$\.\(\)\?\/\\\+\{\}\|])/g, '\\$1'); } function isTagOk(tag) { return tagsWhitelist.indexOf(tag) === -1; } delete words['']; for (word in words) { if ( typeof word === 'string' && words.hasOwnProperty(word) ) { userRegexp = word.match(rIsRegexp); if (userRegexp) { regexs.push( new RegExp(userRegexp[1], 'g') ); } else { regexs.push( new RegExp(prepareRegex(word).replace(/\\?\*/g, function (fullMatch) { return fullMatch === '\\*' ? '*' : '[^ ]*'; }), 'g') ); } replacements.push( words[word] ); } } texts = document.evaluate('//body//text()[ normalize-space(.) != "" ]', document, null, 6, null); for (i = 0; text = texts.snapshotItem(i); i += 1) { if ( isTagOk(text.parentNode.tagName) ) { regexs.forEach(function (value, index) { text.data = text.data.replace( value, replacements[index] ); }); } } }());