TieqViet-ize

Script này sẽ biến mọi trang web của bạn thành Tiếng Việt sau cải cách :)

当前为 2017-11-29 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         TieqViet-ize
// @version      1.0.1
// @description  Script này sẽ biến mọi trang web của bạn thành Tiếng Việt sau cải cách :)
// @author       Dogekutesky's
// @match        *://*/*
// @run-at       document-end
// @require      https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js
// @grant        none
// @namespace https://greasyfork.org/users/123835
// ==/UserScript==

var _typeof='function'==typeof Symbol&&'symbol'==typeof Symbol.iterator?function(a){return typeof a;}:function(a){return a&&'function'==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?'symbol':typeof a;},maps=[['k(h|H)','x'],['K(h|H)','X'],['c(?!(h|H))|q','k'],['C(?!(h|H))|Q','K'],['t(r|R)|c(h|H)','c'],['T(r|R)|C(h|H)','C'],['d|g(i|I)|r','z'],['D|G(i|I)|R','Z'],['g(i|\xEC|\xED|\u1EC9|\u0129|\u1ECB|I|\xCC|\xCD|\u1EC8|\u0128|\u1ECA)','z$1'],['G(i|\xEC|\xED|\u1EC9|\u0129|\u1ECB|I|\xCC|\xCD|\u1EC8|\u0128|\u1ECA)','Z$1'],['\u0111','d'],['\u0110','D'],['p(h|H)','f'],['P(h|H)','F'],['n(g|G)(h|H)?','q'],['N(g|G)(h|H)?','Q'],['(g|G)(h|H)','$1'],['t(h|H)','w'],['T(h|H)','W'],['(n|N)(h|H)','$1\'']];var tieqViet=function(a){if('string'!=typeof a)throw new TypeError('Expected a string, got '+('undefined'==typeof a?'undefined':_typeof(a)));return maps.reduce(function(b,c){return a=a.replace(new RegExp(c[0],'g'),c[1]),a;},a);};
//minified modified version of https://github.com/phanan/tieqviet/blob/master/dist/tieqviet.min.js

function modifyV(f){
    $(f).find('*:not(iframe):not(style):not(span[data-text="true"])').contents().filter(function(){return (this.nodeType == 3) && this.nodeValue.match(/[a-zA-Z_ÀÁÂÃÈÉÊÌÍÒÓÔÕÙÚĂĐĨŨƠàáâãèéêìíòóôõùúăđĩũơƯĂẠẢẤẦẨẪẬẮẰẲẴẶẸẺẼỀỀỂưăạảấầẩẫậắằẳẵặẹẻẽềềểỄỆỈỊỌỎỐỒỔỖỘỚỜỞỠỢỤỦỨỪễệỉịọỏốồổỗộớờởỡợụủứừỬỮỰỲỴÝỶỸửữựỳỵỷỹ]/); }).each(function() {
        var text = tieqViet($(this).text());
        //console.log(text);
        this.nodeValue=text;
    });
}

modifyV('body');

var observer = new MutationObserver(function(mutations) {
    $(mutations).each(function(){
        modifyV($(this.target));
        //console.log($(this.target));

    });
});

var config = {  childList: true, subtree: true };
observer.observe(document.body,config);