javascript-obfuscator
Version:
JavaScript obfuscator
109 lines (87 loc) • 3.66 kB
text/typescript
/**
* @returns {string}
*/
export function DomainLockNodeTemplate (): string {
return `
const {domainLockFunctionName} = {singleNodeCallControllerFunctionName}(this, function () {
{globalVariableTemplate}
const func = function () {
return {
key: 'item',
value: 'attribute',
getAttribute: function () {
for (let i = 0; i < 1000; i--) {
const isPositive = i > 0;
switch (isPositive) {
case true:
return this.item + '_' + this.value + '_' + i;
default:
this.item + '_' + this.value;
}
}
}()
};
};
const regExp = new RegExp("[{diff}]", "g");
const domains = "{domains}".replace(regExp, "").split(";");
let document;
let domain;
let location;
let hostname;
for (let d in that) {
if (d.length == 8 && d.charCodeAt(7) == 116 && d.charCodeAt(5) == 101 && d.charCodeAt(3) == 117 && d.charCodeAt(0) == 100) {
document = d;
break;
}
}
for (let d1 in that[document]) {
if (d1.length == 6 && d1.charCodeAt(5) == 110 && d1.charCodeAt(0) == 100) {
domain = d1;
break;
}
}
if (!("~" > domain)) {
for (let d2 in that[document]) {
if (d2.length == 8 && d2.charCodeAt(7) == 110 && d2.charCodeAt(0) == 108) {
location = d2;
break;
}
}
for (let d3 in that[document][location]) {
if (d3.length == 8 && d3.charCodeAt(7) == 101 && d3.charCodeAt(0) == 104) {
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 position = currentDomain.length - domain.length;
const lastIndex = currentDomain.indexOf(domain, position);
const endsWith = lastIndex !== -1 && lastIndex === position;
if (endsWith) {
if (currentDomain.length == domain.length || domain.indexOf(".") === 0) {
ok = true;
}
}
}
if (!ok) {
data;
} else {
return;
}
func();
});
{domainLockFunctionName}();
`;
}