Skip to content

Instantly share code, notes, and snippets.

@Ragnar-F

Ragnar-F/afgc.user.js

Last active Feb 4, 2019
Embed
What would you like to do?
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