Skip to content

Instantly share code, notes, and snippets.

@danikaze
Last active October 26, 2024 07:23
Show Gist options
  • Save danikaze/1f803cac51248068ae4b42a62416a1b1 to your computer and use it in GitHub Desktop.
Save danikaze/1f803cac51248068ae4b42a62416a1b1 to your computer and use it in GitHub Desktop.
Avoid the anti ad-blocker in SimRacing GP
// ==UserScript==
// @name Simracing GP utils
// @namespace srgp.danikaze
// @version 1.0.0
// @description Avoid the anti ad-blocker in SimRacing GP
// @author danikaze
// @source https://github.com/danikaze/ipesc
// @updateURL https://gist.github.com/danikaze/1f803cac51248068ae4b42a62416a1b1/raw/be30561cd0d5e900f403d39befa5af522209965d/ipesc-remove-anti-adblocker.user.js
// @downloadURL https://gist.github.com/danikaze/1f803cac51248068ae4b42a62416a1b1/raw/be30561cd0d5e900f403d39befa5af522209965d/ipesc-remove-anti-adblocker.user.js
// @match https://app.simracing.gp/*
// @icon https://app.simracing.gp/favicon.ico
// @run-at document-start
// @noframes
// @grant unsafeWindow
// ==/UserScript==
/**! 0.11.0 2024/10/26 16:22:45 JST */
/******/ (() => { // webpackBootstrap
/******/ "use strict";
/******/ var __webpack_modules__ = ({
/***/ "./src/utils/sgp/remove-anti-adblocker.ts":
/*!************************************************!*\
!*** ./src/utils/sgp/remove-anti-adblocker.ts ***!
\************************************************/
/***/ ((__unused_webpack_module, exports) => {
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.removeAntiAdBlocker = removeAntiAdBlocker;
function removeAntiAdBlocker() {
const observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
// Helper function to check the text content recursively in a node and its children
const checkNodeAndChildren = (node) => {
var _a;
if (node instanceof HTMLElement) {
// Check if the node contains the targeted text
if ((_a = node.textContent) === null || _a === void 0 ? void 0 : _a.includes('We’ve Noticed You’re Using an Ad Blocker')) {
console.log('Anti ad-blocker detected!');
// Find the ancestor with class "v-overlay"
const overlayAncestor = node.closest('.v-overlay');
if (overlayAncestor) {
// Remove the ancestor from the DOM
overlayAncestor.remove();
console.log('Anti ad-blocker removed! ;)');
}
}
// Recursively check child nodes
node.childNodes.forEach(checkNodeAndChildren);
}
};
// Check added nodes in mutation
mutation.addedNodes.forEach((node) => {
checkNodeAndChildren(node);
});
});
});
// Observe the entire document for DOM changes
observer.observe(document.body, {
childList: true, // Look for added/removed nodes
subtree: true, // Also observe the entire subtree
});
}
/***/ })
/******/ });
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ var cachedModule = __webpack_module_cache__[moduleId];
/******/ if (cachedModule !== undefined) {
/******/ return cachedModule.exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = __webpack_module_cache__[moduleId] = {
/******/ // no module.id needed
/******/ // no module.loaded needed
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/************************************************************************/
var __webpack_exports__ = {};
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
(() => {
var exports = __webpack_exports__;
/*!*****************************************************!*\
!*** ./src/fns/ipesc-remove-anti-adblocker.user.ts ***!
\*****************************************************/
Object.defineProperty(exports, "__esModule", ({ value: true }));
const remove_anti_adblocker_1 = __webpack_require__(/*! utils/sgp/remove-anti-adblocker */ "./src/utils/sgp/remove-anti-adblocker.ts");
printEnabledMsg();
(0, remove_anti_adblocker_1.removeAntiAdBlocker)();
function printEnabledMsg() {
const reset = 'color: navy;';
const msg = ['%c S%cR%cGP%c utilities enabled!'].join('\n');
console.log(msg, 'border-left: 8px solid navy; color: red; font-weight: bold', 'color: orange; font-weight: bold', 'font-weight: bold; color:black', reset);
}
})();
/******/ })()
;
// ==UserScript==
// @name Simracing GP utils
// @namespace srgp.danikaze
// @version 1.0.0
// @description Avoid the anti ad-blocker in SimRacing GP
// @author danikaze
// @source https://github.com/danikaze/ipesc
// @updateURL https://gist.github.com/danikaze/1f803cac51248068ae4b42a62416a1b1/raw/be30561cd0d5e900f403d39befa5af522209965d/ipesc-remove-anti-adblocker.user.js
// @downloadURL https://gist.github.com/danikaze/1f803cac51248068ae4b42a62416a1b1/raw/be30561cd0d5e900f403d39befa5af522209965d/ipesc-remove-anti-adblocker.user.js
// @match https://app.simracing.gp/*
// @icon https://app.simracing.gp/favicon.ico
// @run-at document-start
// @noframes
// @grant unsafeWindow
// ==/UserScript==
/**! 0.10.0 2024/10/15 22:56:49 JST */
/******/ (() => { // webpackBootstrap
/******/ "use strict";
/******/ var __webpack_modules__ = ({
/***/ "./src/utils/sgp/remove-anti-adblocker.ts":
/*!************************************************!*\
!*** ./src/utils/sgp/remove-anti-adblocker.ts ***!
\************************************************/
/***/ ((__unused_webpack_module, exports) => {
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.removeAntiAdBlocker = removeAntiAdBlocker;
function removeAntiAdBlocker() {
const observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
// Helper function to check the text content recursively in a node and its children
const checkNodeAndChildren = (node) => {
var _a;
if (node instanceof HTMLElement) {
// Check if the node contains the targeted text
if ((_a = node.textContent) === null || _a === void 0 ? void 0 : _a.includes('We’ve Noticed You’re Using an Ad Blocker')) {
console.log('Anti ad-blocker detected!');
// Find the ancestor with class "v-overlay"
const overlayAncestor = node.closest('.v-overlay');
if (overlayAncestor) {
// Remove the ancestor from the DOM
overlayAncestor.remove();
console.log('Anti ad-blocker removed! ;)');
}
}
// Recursively check child nodes
node.childNodes.forEach(checkNodeAndChildren);
}
};
// Check added nodes in mutation
mutation.addedNodes.forEach((node) => {
checkNodeAndChildren(node);
});
});
});
// Observe the entire document for DOM changes
observer.observe(document.body, {
childList: true, // Look for added/removed nodes
subtree: true, // Also observe the entire subtree
});
}
/***/ })
/******/ });
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ var cachedModule = __webpack_module_cache__[moduleId];
/******/ if (cachedModule !== undefined) {
/******/ return cachedModule.exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = __webpack_module_cache__[moduleId] = {
/******/ // no module.id needed
/******/ // no module.loaded needed
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/************************************************************************/
var __webpack_exports__ = {};
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
(() => {
var exports = __webpack_exports__;
/*!*****************************************************!*\
!*** ./src/fns/ipesc-remove-anti-adblocker.user.ts ***!
\*****************************************************/
Object.defineProperty(exports, "__esModule", ({ value: true }));
const remove_anti_adblocker_1 = __webpack_require__(/*! utils/sgp/remove-anti-adblocker */ "./src/utils/sgp/remove-anti-adblocker.ts");
printEnabledMsg();
(0, remove_anti_adblocker_1.removeAntiAdBlocker)();
function printEnabledMsg() {
const reset = 'color: navy;';
const msg = ['%c S%cR%cGP%c utilities enabled!'].join('\n');
console.log(msg, 'border-left: 8px solid navy; color: red; font-weight: bold', 'color: orange; font-weight: bold', 'font-weight: bold; color:black', reset);
}
})();
/******/ })()
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment