Last active
May 25, 2023 09:43
-
-
Save Duologic/6b677bb49dc19c54f9e1dd549c237583 to your computer and use it in GitHub Desktop.
Greasemonkey script to disable Code view <textarea> on Github
This file contains 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 Github: Disable codeview Textarea | |
// @author Duologic | |
// @match https://*.github.com/* | |
// @run-at document-end | |
// ==/UserScript== | |
console.log('Github: Disable codeview Textarea'); | |
const selector = '#read-only-cursor-text-area'; | |
function callback(mutationList, observer) { | |
mutationList.forEach((mutation) => { | |
mutation.addedNodes.forEach((node) => { | |
if (node.querySelector && node.querySelector(selector)) { | |
node.querySelector(selector).disabled=true; | |
console.log('disabled textarea'); | |
} | |
}) | |
}); | |
} | |
const observer = new MutationObserver(callback); | |
observer.observe(document.body, { | |
childList: true, | |
subtree: true | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated the script, turns out the Promise only works on initial load but when switching between code and Markdown preview, the textarea gets recreated. This update ensure we continuously check if there is a textarea on each change.