Userscript to make AutoHotkey Docs easier to translate

Discuss other useful utilities, general computing tips & tricks, Internet resources, etc.
dostroll
Posts: 40
Joined: 03 Nov 2021, 08:56

Userscript to make AutoHotkey Docs easier to translate

03 Apr 2023, 00:51

AutoHotkey Docs currently Codeblock uses the pre tag, but will share a userscript that just makes it a code tag.
The code will not be affected during translation.

Code: Select all

// ==UserScript==
// @name         AutoHotkey Docs
// @version      1
// @description  Converts pre tags to code tags and updates the associated CSS for AutoHotkey documentation pages.
// @match        https://www.autohotkey.com/docs/*
// ==/UserScript==

(function() {
    'use strict';

    // Get all pre tags on the page
    const preTags = document.getElementsByTagName('pre');

    // Loop through each pre tag and replace it with a code tag
    for (let i = 0; i < preTags.length; i++) {
        const preTag = preTags[i];
        const codeTag = document.createElement('code');
        codeTag.innerHTML = preTag.innerHTML;
        preTag.parentNode.replaceChild(codeTag, preTag);
    }

    // Update the CSS for the code tags
    const styleTag = document.createElement('style');
    styleTag.innerHTML = 'code { background-color: #f4f4f4; border: 1px solid #ddd; border-radius: 3px; display: block; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 14px; line-height: 1.4; margin-bottom: 1em; padding: 1em; }';
    document.head.appendChild(styleTag);
})();


Return to “Other Utilities & Resources”

Who is online

Users browsing this forum: No registered users and 78 guests