Created
December 26, 2024 08:03
-
-
Save mq1n/ef0b963854361993a8d05caab11c3480 to your computer and use it in GitHub Desktop.
IPSv4 Cloudflare infinite loop fix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name IPSv4 Cloudflare infinite loop fix | |
| // @namespace http://tampermonkey.net/ | |
| // @version 1.0 | |
| // @description Fixes Cloudflare's infinite captcha loading loop on IPS Board v4 forums by patching service worker registration | |
| // @match https://metin2.dev/* | |
| // @grant none | |
| // @run-at document-start | |
| // ==/UserScript== | |
| (function() { | |
| 'use strict'; | |
| // Override the navigator.serviceWorker.register function | |
| const originalRegister = navigator.serviceWorker.register; | |
| navigator.serviceWorker.register = async function(...args) { | |
| const url = args[0]; | |
| try { | |
| const response = await fetch(url); | |
| let text = await response.text(); | |
| text = text.replace(/.then\(\(response\) => response.json\(\)\)/g, ''); | |
| const blob = new Blob([text], { type: 'application/javascript' }); | |
| const modifiedUrl = URL.createObjectURL(blob); | |
| args[0] = modifiedUrl; | |
| return originalRegister.apply(this, args); | |
| } catch (error) { | |
| console.error('Error modifying service worker:', error); | |
| return originalRegister.apply(this, args); | |
| } | |
| }; | |
| // Unregister existing service worker on page load | |
| window.addEventListener('load', function() { | |
| navigator.serviceWorker.getRegistrations().then(function(registrations) { | |
| for(let registration of registrations) { | |
| registration.unregister(); | |
| } | |
| }); | |
| }); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment