Greasy Fork is available in English.

Discussions » تطوير

Bypassing countdown

§
Posted: 10-08-2024

I have tampermonkey installed and write the following script: http://0x0.st/XWNf.js

but it didn't work for this site: moviesmod.band, any suggestions for improving the script?

§
Posted: 11-08-2024

// ==UserScript==
// @name MoviesMod.band Ad Blocker
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Blocks ads on MoviesMod.band
// @author RenjiYuusei
// @match https://moviesmod.band/*
// @grant none
// ==/UserScript==

(function() {
'use strict';

// Function to remove elements based on CSS selectors
function removeElementsBySelectors(selectors) {
selectors.forEach(selector => {
let elements = document.querySelectorAll(selector);
elements.forEach(element => {
element.remove();
});
});
}

// Selectors for common ad elements on MoviesMod.band
const selectorsToRemove = [
'a[href*="1winpost.com"]', // Example selector for the provided ad
'div[id*="popads"]', // Common pop-up ad container
'iframe[src*="ads"]', // Common ad iframe
// Add more selectors as needed based on the specific ads you see
];

// Remove elements on page load
removeElementsBySelectors(selectorsToRemove);

// Observe the DOM for changes and remove new ad elements
const observer = new MutationObserver(mutations => {
mutations.forEach(mutation => {
mutation.addedNodes.forEach(node => {
if (node instanceof Element) {
selectorsToRemove.forEach(selector => {
if (node.matches(selector)) {
node.remove();
}
});
}
});
});
});

observer.observe(document.body, { childList: true, subtree: true });
})();

§
Posted: 11-08-2024

// ==UserScript==
// @name Override setInterval and setTimeout (Improved)
// @namespace http://tampermonkey.net/
// @version 2024-08-09.1
// @description Bypasses ads by overriding setInterval and setTimeout
// @author You
// @match *://*/*
// @grant none
// ==/UserScript==

(function() {
'use strict';

// Store original functions
const originalSetInterval = window.setInterval;
const originalSetTimeout = window.setTimeout;

// Override setInterval
window.setInterval = function(callback, interval, ...args) {
// If interval is greater than 100ms, reduce it to 1ms
if (interval > 100) {
return originalSetInterval(callback, 1, ...args);
} else {
// Otherwise, use the original setInterval
return originalSetInterval(callback, interval, ...args);
}
};

// Override setTimeout
window.setTimeout = function(callback, delay, ...args) {
// If delay is greater than 100ms, reduce it to 1ms
if (delay > 100) {
return originalSetTimeout(callback, 1, ...args);
} else {
// Otherwise, use the original setTimeout
return originalSetTimeout(callback, delay, ...args);
}
};
})();

§
Posted: 11-08-2024

// ==UserScript==
// @name Override setInterval and setTimeout (Improved)
// @namespace http://tampermonkey.net/
// @version 2024-08-09.1
// @description Bypasses ads by overriding setInterval and setTimeout
// @author You
// @match *://*/*
// @grant none
// ==/UserScript==

(function() {
'use strict';

// Store original functions
const originalSetInterval = window.setInterval;
const originalSetTimeout = window.setTimeout;

// Override setInterval
window.setInterval = function(callback, interval, ...args) {
// If interval is greater than 100ms, reduce it to 1ms
if (interval > 100) {
return originalSetInterval(callback, 1, ...args);
} else {
// Otherwise, use the original setInterval
return originalSetInterval(callback, interval, ...args);
}
};

// Override setTimeout
window.setTimeout = function(callback, delay, ...args) {
// If delay is greater than 100ms, reduce it to 1ms
if (delay > 100) {
return originalSetTimeout(callback, 1, ...args);
} else {
// Otherwise, use the original setTimeout
return originalSetTimeout(callback, delay, ...args);
}
};
})();

You just added a conditional block; how is this supposed to fix the problem on moviesmod.band, RenjiYuusei?

// ==UserScript==
// @name MoviesMod.band Ad Blocker
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Blocks ads on MoviesMod.band
// @author RenjiYuusei
// @match https://moviesmod.band/*
// @grant none
// ==/UserScript==

(function() {
'use strict';

// Function to remove elements based on CSS selectors
function removeElementsBySelectors(selectors) {
selectors.forEach(selector => {
let elements = document.querySelectorAll(selector);
elements.forEach(element => {
element.remove();
});
});
}

// Selectors for common ad elements on MoviesMod.band
const selectorsToRemove = [
'a[href*="1winpost.com"]', // Example selector for the provided ad
'div[id*="popads"]', // Common pop-up ad container
'iframe[src*="ads"]', // Common ad iframe
// Add more selectors as needed based on the specific ads you see
];

// Remove elements on page load
removeElementsBySelectors(selectorsToRemove);

// Observe the DOM for changes and remove new ad elements
const observer = new MutationObserver(mutations => {
mutations.forEach(mutation => {
mutation.addedNodes.forEach(node => {
if (node instanceof Element) {
selectorsToRemove.forEach(selector => {
if (node.matches(selector)) {
node.remove();
}
});
}
});
});
});

observer.observe(document.body, { childList: true, subtree: true });
})();

And it only remove a html element, not a countdown.

Post reply

تسجيل الدخول إلى مرحلة ما بعد الرد.