123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- /**
- * @returns {string}
- */
- export function DomainLockTemplate (): string {
- return `
- const {domainLockFunctionName} = {callControllerFunctionName}(this, function () {
-
- {globalVariableTemplate}
-
- const regExp = new RegExp("[{domainsStringDiff}]", "g");
- const domains = "{domains}".replace(regExp, "").split(";");
- let document;
- let domain;
- let location;
- let hostname;
- const isName = function(name, length, cs) {
- if (name.length != length) {
- return false;
- }
- for (let i = 0; i < length; i++) {
- for (let j = 0; j < cs.length; j += 2) {
- if (i == cs[j] && name.charCodeAt(i) != cs[j+1]) {
- return false;
- }
- }
- }
- return true;
- };
- const isNameVariant1 = function(cs, name, length) {
- return isName(name, length, cs);
- };
- const isNameVariant2 = function(name, cs, length) {
- return isNameVariant1(cs, name, length);
- };
- const isNameVariant3 = function(length, name, cs) {
- return isNameVariant2(name, cs, length);
- };
- for (let d in that) {
- if (isName(d, 8, [7, 116, 5, 101, 3, 117, 0, 100])) {
- document = d;
-
- break;
- }
- }
- for (let d1 in that[document]) {
- if (isNameVariant3(6, d1, [5, 110, 0, 100])) {
- domain = d1;
- break;
- }
- }
- for (let d2 in that[document]) {
- if (isNameVariant2(d2, [7, 110, 0, 108], 8)) {
- location = d2;
- break;
- }
- }
- if (!("~" > domain)) {
- for (let d3 in that[document][location]) {
- if (isNameVariant1([7, 101, 0, 104], d3, 8)) {
- hostname = d3;
-
- break;
- }
- }
- }
-
- if (!document || !that[document]) {
- return;
- }
-
- const documentDomain = that[document][domain];
- const documentLocationHostName = !!that[document][location] && that[document][location][hostname];
- const currentDomain = documentDomain || documentLocationHostName;
-
- if (!currentDomain) {
- return;
- }
-
- let ok = false;
-
- for (let i = 0; i < domains.length; i++) {
- const domain = domains[i];
- const domainNormalized = domain[0] === String.fromCharCode(46)
- ? domain.slice(1)
- : domain;
- const position = currentDomain.length - domainNormalized.length;
- const lastIndex = currentDomain.indexOf(domainNormalized, position);
- const endsWith = lastIndex !== -1 && lastIndex === position;
-
- if (endsWith) {
- if (currentDomain.length == domain.length || domain.indexOf(".") === 0) {
- ok = true;
- }
- }
- }
- if (!ok) {
- const regExp2 = new RegExp("[{domainLockRedirectUrlDiff}]", "g");
- const domainLockRedirectUrl = "{hiddenDomainLockRedirectUrl}".replace(regExp2, "");
- that[document][location] = domainLockRedirectUrl;
- }
- });
- {domainLockFunctionName}();
- `;
- }
|