YaConnect.TranslitEmail

Script for Yandex.Connect to transliterate name and surname to mail address

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name YaConnect.TranslitEmail
// @description Script for Yandex.Connect to transliterate name and surname to mail address
// @author Antiokh
// @license MIT
// @version 1.1
// @include https://connect.yandex.ru/portal/admin*
// @require        https://code.jquery.com/jquery-3.2.1.min.js
// @namespace https://greasyfork.org/users/395037
// ==/UserScript==

// wrap the script in a closure (opera, ie)
// do not spoil the global scope
// The script can be transformed into a bookmarklet easily :)
(function(window, undefined ) {

	// normalized window
	var w;
	if (unsafeWindow != "undefined"){
		w = unsafeWindow
	} else {
		w = window;
	}

	// You can inject almost any javascript library here.
	// Just pass the w as the window reference,
        // e.g. jquery.min.js embedding:
	// (function(a,b){function ci(a) ... a.jQuery=a.$=d})(w);


	// do not run in frames
	if (w.self != w.top){
		return;
	}

	// additional url check.
	// Google Chrome do not treat @match as intended sometimes.
	if (/https:\/\/connect.yandex.ru\/portal\/admin/.test(w.location.href)){
		//Below is the userscript code itself


        function bindemail() {
            try {
                makeemail();
            } catch (err) {}
        }
			function transliterate(text, engToRus) {
					var rus = "\u0449   \u0448  \u0447  \u0446  \u044E  \u044F  \u0451  \u0436  \u044A  \u044B  \u044D  \u0430 \u0431 \u0432 \u0433 \u0434 \u0435 \u0437 \u0438 \u0439 \u043A \u043B \u043C \u043D \u043E \u043F \u0440 \u0441 \u0442 \u0443 \u0444 \u0445 \u044C".split(/ +/g);
					var eng = "shh sh ch ts yu ya yo zh '' y  e  a b v g d e z i j k l m n o p r s t u f kh '".split(/ +/g);
					var x;
					for(x = 0; x < rus.length; x++) {
						text = text.split(engToRus ? eng[x] : rus[x]).join(engToRus ? rus[x] : eng[x]);
						text = text.split(engToRus ? eng[x].toUpperCase() : rus[x].toUpperCase()).join(engToRus ? rus[x].toUpperCase() : eng[x].toUpperCase());
					}
					return text;
			}

			function makeemail() { $('div.user-nickname input').val((transliterate($('input[name="name[first][ru]"]').val()).charAt(0) + '.' + transliterate($('input[name="name[last][ru]"]').val())).toLowerCase().replace("'",""));
								 }

$(document).ready(function() {
    let timerId = setInterval(bindemail, 200);
});





	}
})(window);