Skip to content

Instantly share code, notes, and snippets.

@abstraction
Created July 11, 2024 17:19
Show Gist options
  • Save abstraction/d7cbab067f3c3a075807733d13871e1b to your computer and use it in GitHub Desktop.
Save abstraction/d7cbab067f3c3a075807733d13871e1b to your computer and use it in GitHub Desktop.
// Remove element with id "s65c" from the DOM
document.getElementById("s65c").parentNode.removeChild(document.getElementById("s65c"));
(function(global) {
function executeNextFunction() {
// If functions remain in the queue, execute the next one
if (functionQueue.length) {
functionQueue[0]();
}
}
// Reference to the document object
var doc = global.document;
// Queue of functions to be executed
var functionQueue = ["checkAds", "checkImages"];
// Helper function to get a random integer
function getRandomInt(max) {
return Math.floor(Math.random() * max);
}
// Helper function to get an element by id or tag name
function getElement(idOrTag, tag) {
return idOrTag ? doc.getElementById(idOrTag) : doc.getElementsByTagName(tag);
}
// Helper function to get computed style of an element
function getStyle(element) {
var view = doc.defaultView;
return view && view.getComputedStyle ? view.getComputedStyle(element, null) : element.currentStyle;
}
// Helper function to defer execution of a function
function deferExecution(fn) {
setTimeout(fn, 2000);
}
// Helper function to insert HTML into the document
function insertHTML(html, id) {
var span = doc.createElement("span"),
body = doc.body,
childCount = body.childNodes.length,
bodyStyle = body.style,
highestZIndex = 0;
if (id === "s65c") {
span.setAttribute("id", id);
bodyStyle.margin = bodyStyle.padding = 0;
bodyStyle.height = "100%";
// Find the highest z-index of child elements
for (var i = getRandomInt(childCount); i < childCount; i++) {
if (body.childNodes[i].nodeType === 1) { // Element node
highestZIndex = Math.max(highestZIndex, parseFloat(getStyle(body.childNodes[i]).zIndex) || 0);
}
}
if (highestZIndex) {
span.style.zIndex = highestZIndex + 1;
}
}
span.innerHTML = html;
body.insertBefore(span, body.childNodes[childCount - 1]);
}
// Function to display a message in the document
function displayMessage() {
var randomChar = "abisuq".charAt(getRandomInt(5));
insertHTML(
`<${randomChar}><div class="card card-body bg-light">
<img src="https://i.imgur.com/ne03PNi.png" />
<button type="button" class="btn btn-dark" onclick="window.location.reload();">Ok</button>
</div></${randomChar}>`,
"s65c"
);
// Add event listener to re-display the message if the node is removed
if (doc.addEventListener) {
deferExecution(function() {
getElement("s65c").addEventListener("DOMNodeRemoved", function() {
displayMessage();
}, false);
});
}
}
// Function to check for the presence of ad elements
function checkAds() {
var adElements = "adContext,ad_img,adv_62,downloadAd,onpageads,topBannerAd,weatherad,ad,ads,adsense".split(","),
adElementsLength = adElements.length,
html = "",
randomChar = "abisuq".charAt(getRandomInt(5));
// Create ad elements if they do not exist
for (var i = 0; i < adElementsLength; i++) {
if (!getElement(adElements[i])) {
html += `<${randomChar} id="${adElements[i]}"></${randomChar}>`;
}
}
insertHTML(html);
// Check if the ad elements are hidden and display the message if so
deferExecution(function() {
for (var i = 0; i < adElementsLength; i++) {
var adElement = getElement(adElements[i]);
if (adElement === null || adElement.offsetParent === null || getStyle(adElement).display === "none") {
return displayMessage(`#${adElements[i]}(${i})`);
}
}
executeNextFunction();
});
}
// Function to check the images
function checkImages() {
var disallowedSources = "-page-peel/,/adnetwork468.,/ads/reskins/ad,/adweb33.,/awepop.,/ban300.html,/banner/ad.,/displayads/ad,/webadvert3/ad,_728_90_".split(","),
images = getElement(0, "img");
if (images[0] !== undefined && images[0].src !== undefined) {
var image = new Image();
image.onload = function() {
image.onload = null;
image.onerror = function() {
functionQueue = null;
displayMessage(image.src);
};
image.src = images[0].src + "#" + disallowedSources.join("");
};
image.src = images[0].src;
}
deferExecution(function() {
executeNextFunction();
});
}
// Function constructor
function AntiAdBlock() {}
AntiAdBlock.prototype = {
rand: getRandomInt,
getElementBy: getElement,
getStyle: getStyle,
deferExecution: deferExecution,
insert: insertHTML,
displayMessage: displayMessage,
checkAds: checkAds,
checkImages: checkImages,
nextFunction: executeNextFunction
};
// Initialize the anti-adblock functionality
global.s65c = new AntiAdBlock();
if (doc.addEventListener) {
global.addEventListener("load", AntiAdBlock, false);
} else {
global.attachEvent("onload", AntiAdBlock);
}
})(window);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment