ogenerationify

olds' generation

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name		 ogenerationify
// @version	  4.1999.5
// @description  olds' generation
// @include	  https://*hkgalden.com/view*
// @include	  http://*hkgalden.com/view*
// @copyright	1999
// @namespace	1999oldman
// ==/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 getRandBool = function(){
	return Math.round(Math.random()) < 1;
};
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 getRandBool() ? '=' : '-';
};
var getRandQuote = function(){
	return getRandBool() ? (getRandBool() ?['(((',')))'] : [' >>> ','>>> ']) : (getRandBool() ? ['[',']'] : [' ',' ']);
};
var ogenerationify = function(text){
	var rq = getRandQuote();
	text = text.replace(/唔/g, getRandBool() ? '吾' : '唔')
	.replace(/但/g, 'but')
	.replace(/女/g, '囡')
	.replace(/我/g, '阿叔' + (getRandBool() ? '' : '我'))
	.replace(/係/g, getRandBool() ? '糸' : '係')
	.replace(/喎/g, '咼')
	.replace(/好/g, '#good#')
	.replace(/撚(頭|樣)/g, '蒙$1')
	.replace(/老一輩/g, '老#good#輩')
	.replace(/啦/g, 'la')
	.replace(/子|仔/g, getRandBool() ? '仔' : '囝')
	.replace(/ {2,}(.+?) {2,}/, ' '+rq[0]+' $1 '+rq[1]+' ');
    var startStrike = getRandStrike().repeat(rand(4,16));
    text = startStrike + (getRandBool() ? '\n' : ' ') + text;
	for(var i = 0; i < rand(1, Math.round(text.length / 2)); i++){
		var rp = rand(0, text.length - 1);
		if(text.charCodeAt(rp) > 255 || /(\s|=|-)/.test(text.charAt(rp))){
            var rc = getRandBool() ? (getRandBool() ? getRandEmotion() : ' ') : (getRandBool() ? (Math.round(Math.random() * 10) > 6 ? '  ' : '\n') : (getRandBool() ? '..'.repeat(2,4) : getRandStrike().repeat(rand(1,8))));
			text = text.insertAt(rp, rc);
		}
	}
	text += getRandBool() ? getRandEmotion() : getRandEmotion() + getRandStrike().repeat(rand(4,16));
	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;
	});
    unsafeWindow.ogenerationified = !1;
    for(var i = 0; i < clickEvts.length; i++){
		var origHandler = clickEvts[i].handler,
            origSelector = clickEvts[i].selector;
		clickEvts[i].handler = function(e){
            e.preventDefault();
            var ctn = $('#gae #ta');
            ctn.val(ogenerationify(ctn.val()));
            if(origSelector.indexOf('temp') < 0) origHandler(e);
		};
	}
},1000);