Last active
April 10, 2026 19:31
A Tampermonkey userscript that automatically clicks the Cloudflare Turnstile non interactive captcha by bypassing some of its security measures
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 AutoFlare | |
| // @namespace https://gist.github.com/Meterel/1941f0c156f5f86aafdbddf5f19da42e | |
| // @version 4 | |
| // @description A Tampermonkey userscript that automatically clicks the Cloudflare Turnstile non interactive captcha by bypassing some of its security measures | |
| // @author Meterel | |
| // @updateURL https://gist.githubusercontent.com/Meterel/1941f0c156f5f86aafdbddf5f19da42e/raw/AutoFlare.user.js | |
| // @downloadURL https://gist.githubusercontent.com/Meterel/1941f0c156f5f86aafdbddf5f19da42e/raw/AutoFlare.user.js | |
| // @match https://challenges.cloudflare.com/cdn-cgi/challenge-platform/*/turnstile/* | |
| // @run-at document-body | |
| // @grant none | |
| // ==/UserScript== | |
| /* | |
| MIT License | |
| Copyright (c) 2025-2026 Meterel | |
| Permission is hereby granted, free of charge, to any person obtaining a copy | |
| of this software and associated documentation files (the "Software"), to deal | |
| in the Software without restriction, including without limitation the rights | |
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| copies of the Software, and to permit persons to whom the Software is | |
| furnished to do so, subject to the following conditions: | |
| The above copyright notice and this permission notice shall be included in all | |
| copies or substantial portions of the Software. | |
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
| SOFTWARE. | |
| */ | |
| //must @run-at document-body instead of document-start because it may run without <head> | |
| (function() { | |
| 'use strict'; | |
| //has to be injected this way due to csp | |
| const s=document.createElement("script"); | |
| s.innerHTML=` | |
| document.head.firstElementChild.remove(); //removes itself | |
| let fakeTrustedEvent=false; | |
| EventTarget.prototype.addEventListener=new Proxy(EventTarget.prototype.addEventListener,{ //proxy must be used or else cloudflare detects it, modifying event types with proxy gives interface not supported errors | |
| apply(func,that,args){ | |
| const oldHandler=args[1]; | |
| args[1]=function(...x){ //arrow funcs dont preserve this | |
| if(fakeTrustedEvent){ | |
| x[0]=new Proxy(x[0],{ | |
| get(o,p){ | |
| if(p==="isTrusted") return true; | |
| return o[p]; //Reflect.get(...arguments) throws | |
| } | |
| }); | |
| } | |
| return oldHandler(...x); | |
| }; | |
| return Reflect.apply(func,that,args); | |
| } | |
| }); | |
| Element.prototype.attachShadow=new Proxy(Element.prototype.attachShadow,{ | |
| apply(x,y,z){ | |
| const shadow=Reflect.apply(x,y,z); | |
| const observer=new MutationObserver(()=>{ | |
| const i=shadow.querySelector("input[type='checkbox']"); | |
| if(!i) return; | |
| observer.disconnect(); | |
| fakeTrustedEvent=true; | |
| i.dispatchEvent(new PointerEvent("click",{bubbles:true,cancelable:true,composed:true,isPrimary:true,pointerId:-1,view:window})); //i.dispatchEvent(new PointerEvent("click")) also works | |
| fakeTrustedEvent=false; //dispatchEvent causes multiple events to be fired, therefore this shouldnt be set in the event handler | |
| }); | |
| observer.observe(shadow,{subtree:true,childList:true}); //<input> gets created, not made visible with attributes | |
| return shadow; | |
| } | |
| }); | |
| `; | |
| s.nonce=document.head.querySelector("meta[http-equiv='content-security-policy']").content.match(/nonce-(\w+)/)[1]; //GM_addElement doesnt work because no nonce, might be a tampermonkey bug | |
| s.type="module"; | |
| document.head.prepend(s); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment