Raw Source
iSkile / Replace lightshot and joxi links

// ==UserScript==
// @name         Replace lightshot and joxi links
// @version      0.5
// @description  Makes links to pictures from "Ligthshot" and "joxi" by direct
// @updateURL    https://openuserjs.org/meta/iSkile/Replace_lightshot_links.meta.js
// @author       iSkile
// @run-at       document-idle
// @include      *://*/*
// @grant        none
// ==/UserScript==
/* jshint -W097 */
'use strict';

if (~['prnt.sc'].indexOf(location.hostname)) {
    if (/\/prnt\.sc\/\w+$/i.test(location.href)) {
        location.href += '/direct';
        throw new Error('redirect');
    }
}

if (~['joxi.ru'].indexOf(location.hostname)) {
    if (/\/joxi\.ru\/\w+$/i.test(location.href)) {
        location.href += '?d=1';
        throw new Error('redirect');
    }
}

function replace(root) {
    var links = root.querySelectorAll('a[href*="://prntscr.com/"], a[href*="://prnt.sc/"], a[href*="://joxi.ru/"]');

    for (let link of links) {
        if (/\/(prntscr\.com|prnt\.sc)\/\w+$/i.test(link.href)) {
            //console.log(link);
            link.href += '/direct';
        }
        else if (/\/joxi\.ru\/\w+$/i.test(link.href)) {
            //console.log(link);
            link.href += '?d=1';
        }
    }
}

var observer = new MutationObserver(function(mutations) {
    mutations.forEach(function(mutation) {
        mutation.addedNodes.forEach(function(addedNode) {
            if (addedNode.nodeType === 1) {
                replace(addedNode);
            }
        });
    });
});

observer.observe(document.documentElement, {
    childList: true,
    subtree: true
});

replace(document.body);