commit
15bf81ca12
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"manifest_version": 3,
|
"manifest_version": 3,
|
||||||
"name": "Cookie Dialog Monster",
|
"name": "Cookie Dialog Monster",
|
||||||
"version": "6.4.3",
|
"version": "6.4.4",
|
||||||
"default_locale": "en",
|
"default_locale": "en",
|
||||||
"description": "__MSG_appDesc__",
|
"description": "__MSG_appDesc__",
|
||||||
"icons": {
|
"icons": {
|
||||||
|
@ -46,12 +46,16 @@ const storage = chrome.storage.local;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
const refreshData = (callback) => {
|
const refreshData = (callback) => {
|
||||||
fetch(`${apiUrl}/data/`).then((result) => {
|
try {
|
||||||
result.json().then(({ data }) => {
|
fetch(`${apiUrl}/data/`).then((result) => {
|
||||||
chrome.storage.local.set({ data });
|
result.json().then(({ data }) => {
|
||||||
callback?.(data);
|
chrome.storage.local.set({ data });
|
||||||
|
callback?.(data);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
} catch {
|
||||||
|
refreshData(callback);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,7 +16,7 @@ const dispatch = chrome.runtime.sendMessage;
|
|||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const hostname = document.location.hostname.split('.').slice(-3).join('.').replace('www.', '');
|
const hostname = getHostname();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Options provided to observer
|
* @description Options provided to observer
|
||||||
@ -80,6 +80,22 @@ function forceElementStyles(element) {
|
|||||||
element.style.setProperty('display', 'none', 'important');
|
element.style.setProperty('display', 'none', 'important');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description Calculates current hostname
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
|
||||||
|
function getHostname() {
|
||||||
|
let hostname = document.location.hostname;
|
||||||
|
const referrer = document.referrer;
|
||||||
|
|
||||||
|
if (referrer) {
|
||||||
|
hostname = new URL(referrer).hostname;
|
||||||
|
}
|
||||||
|
|
||||||
|
return hostname.split('.').slice(-3).join('.').replace('www.', '');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Checks if an element is visible in the viewport
|
* @description Checks if an element is visible in the viewport
|
||||||
* @param {HTMLElement} element
|
* @param {HTMLElement} element
|
||||||
@ -177,7 +193,7 @@ function fix() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (skips.some((x) => !hostname.match(x.replace(/\*/g, '[^ ]*')))) {
|
if (skips.every((x) => !hostname.match(x.replace(/\*/g, '[^ ]*')))) {
|
||||||
for (const element of [document.body, document.documentElement]) {
|
for (const element of [document.body, document.documentElement]) {
|
||||||
element?.classList.remove(...(data?.classes ?? []));
|
element?.classList.remove(...(data?.classes ?? []));
|
||||||
element?.style.setProperty('position', 'initial', 'important');
|
element?.style.setProperty('position', 'initial', 'important');
|
||||||
@ -280,7 +296,7 @@ window.addEventListener('pageshow', (event) => {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
window.addEventListener('run', () => {
|
window.addEventListener('run', () => {
|
||||||
if (data?.elements.length && state.enabled && !preview) {
|
if (data?.elements.length && document.body && state.enabled && !preview) {
|
||||||
if (readingTime() < 4) {
|
if (readingTime() < 4) {
|
||||||
forceClean(document.body);
|
forceClean(document.body);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user