Last active
February 24, 2026 16:32
-
-
Save PedroHLC/f6f238834f5ebdfaff5c1bf907745fcb to your computer and use it in GitHub Desktop.
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 Disable Turbo on GitHub | |
| // @namespace https://gist.github.com/PedroHLC/f6f238834f5ebdfaff5c1bf907745fcb | |
| // @version 1.0.8 | |
| // @author PedroHLC, Claude | |
| // @description Completely disables Turbo Drive on GitHub | |
| // @match https://github.com/* | |
| // @run-at document-start | |
| // @grant none | |
| // @updateURL https://gist.github.com/PedroHLC/f6f238834f5ebdfaff5c1bf907745fcb/raw/github-nuke-turbo.user.js | |
| // @downloadURL https://gist.github.com/PedroHLC/f6f238834f5ebdfaff5c1bf907745fcb/raw/github-nuke-turbo.user.js | |
| // ==/UserScript== | |
| (function() { | |
| // GitHub checks this meta tag natively | |
| const meta = document.createElement('meta'); | |
| meta.name = 'disable-turbo'; | |
| meta.content = 'true'; | |
| // Belt-and-suspenders: also set the standard turbo visit control | |
| const meta2 = document.createElement('meta'); | |
| meta2.name = 'turbo-visit-control'; | |
| meta2.content = 'reload'; | |
| // Insert meta tags into <head> once it exists | |
| new MutationObserver((_, obs) => { | |
| if (document.head) { | |
| document.head.prepend(meta2); | |
| document.head.prepend(meta); | |
| obs.disconnect(); | |
| } | |
| }).observe(document.documentElement, { childList: true }); | |
| // After Turbo boots, just disconnect it entirely | |
| document.addEventListener('turbo:load', function() { | |
| if (window.Turbo?.session) { | |
| window.Turbo.session.drive = false; | |
| window.Turbo.session.disconnect(); | |
| } | |
| }, { once: true }); | |
| // Intercept Turbo navigations | |
| document.addEventListener('turbo:before-visit', function(e) { | |
| e.preventDefault(); | |
| window.location.href = e.detail.url; | |
| }); | |
| document.addEventListener('turbo:before-fetch-request', function(e) { | |
| const frame = e.target.closest('turbo-frame'); | |
| if (frame) { | |
| e.preventDefault(); | |
| const url = e.detail.url?.href || e.detail.url; | |
| if (url) window.location.href = url; | |
| } | |
| }); | |
| // Intercepts renders | |
| document.addEventListener('turbo:before-render', function(e) { | |
| // Patch the incoming page before it gets rendered | |
| const newBody = e.detail.newBody; | |
| if (newBody) { | |
| newBody.querySelectorAll?.('meta[name="disable-turbo"]').forEach(m => { | |
| m.content = 'true'; | |
| }); | |
| } | |
| // Also patch the new head if available | |
| const newHead = e.detail.newHead; | |
| if (newHead) { | |
| newHead.querySelectorAll?.('meta[name="disable-turbo"]').forEach(m => { | |
| m.content = 'true'; | |
| }); | |
| } | |
| }); | |
| // Kill prefetch | |
| document.addEventListener('turbo:before-prefetch', function(e) { | |
| e.preventDefault(); | |
| }); | |
| // Disable Turbo.session.drive when it initializes | |
| Object.defineProperty(window, 'Turbo', { | |
| set(val) { | |
| if (val && val.session) { | |
| val.session.drive = false; | |
| } | |
| this._Turbo = val; | |
| }, | |
| get() { return this._Turbo; }, | |
| configurable: true | |
| }); | |
| // Flip GitHub's own disable-turbo meta to true | |
| new MutationObserver((mutations) => { | |
| for (const m of mutations) { | |
| for (const node of m.addedNodes) { | |
| if (node.nodeType === 1 && node.tagName === 'META' && node.name === 'disable-turbo') { | |
| node.content = 'true'; | |
| } | |
| } | |
| } | |
| }).observe(document.documentElement, { childList: true, subtree: true }); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment