Publish Auto Mirror Switcher 1.4.3 with installation and privacy documentation
This commit is contained in:
commit
5052f542de
33 files changed
+4912
No files matched your search
+108
@@ -0,0 +1,108 @@
|
||||
(function (root) {
|
||||
'use strict';
|
||||
|
||||
var S = root.AutoMirrorShared;
|
||||
|
||||
function findBlockedMarker(rule) {
|
||||
return S.findBlockedMarkerInPage(
|
||||
rule,
|
||||
document.title || '',
|
||||
document.body ? document.body.innerText : ''
|
||||
);
|
||||
}
|
||||
|
||||
function sendDebug(event, data, level) {
|
||||
try {
|
||||
chrome.runtime.sendMessage({
|
||||
type: 'DEBUG_LOG',
|
||||
level: level || 'debug',
|
||||
event: event,
|
||||
data: data || {}
|
||||
});
|
||||
} catch (e) {
|
||||
// Diagnostics must never break the page.
|
||||
}
|
||||
}
|
||||
|
||||
function reportBlocked(rule, marker) {
|
||||
chrome.runtime.sendMessage({
|
||||
type: 'BLOCKED_PAGE_DETECTED',
|
||||
url: location.href,
|
||||
marker: marker || '',
|
||||
rule: rule && (rule.name || rule.id) || '',
|
||||
title: document.title || ''
|
||||
});
|
||||
}
|
||||
|
||||
function reportOk(rule) {
|
||||
chrome.runtime.sendMessage({
|
||||
type: 'PAGE_OK',
|
||||
url: location.href,
|
||||
rule: rule && (rule.name || rule.id) || '',
|
||||
title: document.title || ''
|
||||
});
|
||||
}
|
||||
|
||||
function run() {
|
||||
chrome.storage.local.get({ enabled: true, rules: [] }, function (items) {
|
||||
if (items.enabled === false || !Array.isArray(items.rules)) return;
|
||||
|
||||
var rule = S.findRuleForHost(items.rules, location.hostname);
|
||||
if (!rule) return;
|
||||
|
||||
sendDebug('content.ruleMatched', {
|
||||
url: location.href,
|
||||
host: location.hostname,
|
||||
rule: rule.name || rule.id || 'unknown',
|
||||
mode: rule.mode || 'step',
|
||||
strategy: rule.strategy || 'number'
|
||||
});
|
||||
|
||||
var delays = [0, 150, 600, 1800, 4200];
|
||||
var reported = false;
|
||||
|
||||
delays.forEach(function (delay, index) {
|
||||
root.setTimeout(function () {
|
||||
if (reported) return;
|
||||
|
||||
var marker = findBlockedMarker(rule);
|
||||
|
||||
if (marker) {
|
||||
reported = true;
|
||||
sendDebug('content.blockedMarkerFound', {
|
||||
url: location.href,
|
||||
host: location.hostname,
|
||||
rule: rule.name || rule.id || 'unknown',
|
||||
marker: marker,
|
||||
checkDelayMs: delay,
|
||||
title: document.title || ''
|
||||
}, 'warn');
|
||||
reportBlocked(rule, marker);
|
||||
return;
|
||||
}
|
||||
|
||||
sendDebug('content.markerCheckClean', {
|
||||
url: location.href,
|
||||
host: location.hostname,
|
||||
rule: rule.name || rule.id || 'unknown',
|
||||
checkDelayMs: delay,
|
||||
checkIndex: index + 1,
|
||||
totalChecks: delays.length,
|
||||
title: document.title || ''
|
||||
});
|
||||
|
||||
if (index === delays.length - 1) {
|
||||
reported = true;
|
||||
reportOk(rule);
|
||||
}
|
||||
}, delay);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', run);
|
||||
} else {
|
||||
run();
|
||||
}
|
||||
})(typeof globalThis !== 'undefined' ? globalThis : this);
|
||||
Reference in new issue
Block a user