// ==UserScript== // @name ogenerationify // @version 0.1999 // @description olds' generation // @include https://*hkgalden.com/view* // @include http://*hkgalden.com/view* // @copyright 1999 // @namespace 1999oldman // @downloadURL none // ==/UserScript== String.prototype.repeat = function(num){ return new Array(num + 1).join(this); }; String.prototype.insertAt = function(idx,str){ return this.substr(0, idx) + str + this.substr(idx); }; var rand = function(min,max){ return Math.floor(Math.random() * (max - min + 1) + min); }; var getRandEmotion = function(){ var a = ['[369]','#adore#','#yup#','O:-)',':-[','#ass#','[banghead]',':D','[bomb]','[bouncer]','[bouncy]','#bye#','[censored]','#cn#',':o)',':~(','xx(',':-]','#ng#','#fire#','[flowerface]',':-(','fuck','@_@','#good#','#hehe#','#hoho#','#kill2#','#kill#','^3^','#love#','#no#','[offtopic]',':O','[photo]','[shocking]','[slick]',':)','[sosad]','#oh#',':P',';-)','???','?_?','[yipes]','Z_Z']; return a[Math.floor(Math.random() * a.length)]; }; var getRandStrike = function(){ return Math.round(Math.random()) < 1 ? '=' : '-'; }; var getRandQuote = function(){ return Math.round(Math.random()) < 1 ? ['(((',')))'] : ['[',']']; }; var ogenerationify = function(text){ for(var i = 0; i < rand(1, Math.max(Math.ceil(text.length / 1.75), 4)); i++){ var rp = rand(0, text.length - 1); if(text.charCodeAt(rp) > 255 || /(\s|=|-)/.test(text.charAt(rp))){ var rc = Math.round(Math.random()) < 1 ? getRandEmotion() : (Math.round(Math.random()) < 1 ? '\n' : (Math.round(Math.random()) < 1 ? '..'.repeat(1,4) : (Math.round(Math.random()) < 1 ? getRandStrike().repeat(rand(1,12)) : ' '))); text = text.insertAt(rp, rc); } } var rq = getRandQuote(); text = text.replace(/唔/g, Math.round(Math.random()) < 1 ? '吾' : '唔') .replace(/但/g, 'but') .replace(/女/g, '囡') .replace(/係/g, '糸') .replace(/子|仔/g, Math.round(Math.random()) < 1 ? '仔' : '囝') .replace(/(\s)(.*?)(\s)/, '$1'+rq[0]+' $2 '+rq[1]+'$3'); text = getRandStrike().repeat(rand(4,24)) + text; text += Math.round(Math.random()) < 1 ? getRandEmotion() : getRandEmotion() + getRandStrike().repeat(rand(4,24)); return text; }; setTimeout(function(){ $('#fast_reply [id*="submit_fast_reply"]').click(); $('#fpy').removeClass('fcs'); $('#hkga-noti').empty(); var clickEvts = $.grep($._data(document, 'events').click, function(e){ return e.selector && e.selector.indexOf('submit_fast_reply') > 0 && e.handler.toString().indexOf('/ajax/fastreply') > 0; }); $.each(clickEvts, function(){ var origHandler = this.handler; this.handler = function(e){ e.preventDefault(); var ctn = $('#gae #ta'); ctn.val(ogenerationify(ctn.val())); origHandler(e); }; }); },1000);