Last active
November 25, 2023 19:33
-
-
Save Ragnar-F/335e717c5e9651c932bf507fb5e75200 to your computer and use it in GitHub Desktop.
Userscript for AutoHotkey Forum German Codeboxes
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 AutoHotkey Forum German Codeboxes | |
// @namespace https://www.autohotkey.com/boards/* | |
// @version 0.4 | |
// @description Replaces english doc links in the codeboxes with the german counterparts | |
// @author Ragnar-F | |
// @match https://www.autohotkey.com/boards/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
waitForFnc(); | |
function forEachElement(selector, fn) { | |
var elements = document.querySelectorAll(selector); | |
for (var i = 0; i < elements.length; i++) { | |
fn(elements[i], i); | |
} | |
} | |
function waitForFnc() { | |
if (typeof codelinkstyle == 'undefined') { | |
window.setTimeout(waitForFnc, 50); | |
} | |
else { | |
forEachElement("pre.language-autohotkey a", function(el, i) { | |
var url = el.href, idx = url.indexOf("#"), query; | |
query = url.substring(url.indexOf('=')+1, url.length); | |
if (el.firstChild.className.indexOf('token important') != -1) { // if directive | |
query = '#' + query; | |
} | |
query = encodeURIComponent(query); // for queries such as "=" or "#NoEnv" | |
el.href = 'https://ahkde.github.io/docs/search.htm?q=' + query + '&m=1'; | |
}); | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment