Skip to content

Instantly share code, notes, and snippets.

@Ragnar-F
Last active November 25, 2023 19:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ragnar-F/335e717c5e9651c932bf507fb5e75200 to your computer and use it in GitHub Desktop.
Save Ragnar-F/335e717c5e9651c932bf507fb5e75200 to your computer and use it in GitHub Desktop.
Userscript for AutoHotkey Forum German Codeboxes
// ==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