ETI Image Redirector

changes images from linking to their imagemap to their image page

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

You will need to install an extension such as Tampermonkey to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name        ETI Image Redirector
// @namespace   pendevin
// @description changes images from linking to their imagemap to their image page
// @include     http://boards.endoftheinter.net/showmessages.php*
// @include     http://archives.endoftheinter.net/showmessages.php*
// @include     http://endoftheinter.net/inboxthread.php*
// @include     https://boards.endoftheinter.net/showmessages.php*
// @include     https://archives.endoftheinter.net/showmessages.php*
// @include     https://endoftheinter.net/inboxthread.php*
// @require     http://code.jquery.com/jquery-2.1.4.min.js
// @version     1
// @grant       none
// ==/UserScript==

//ll breaks without noconflict jquery
this.$ = this.jQuery = jQuery.noConflict(true);

//livelinks compatiblity *JQUERY
//calls the function on each message-container in a document, including ones added by livelinks
//place is an optional specialized location
function livelinks(func, extraParams, place) {
    if (extraParams == undefined) {
        extraParams = null;
    }
    if (place == undefined) {
        place = '.message-container';
    }
    //run the function on the message-containers currently on the page
    $('#u0_1 ' + place).each(function(i, container) {
        func(container, extraParams);
    });
    //make mutationobserver to run junk on matches
    var observer = new MutationObserver(function(mutations) {
        mutations.forEach(function(mutation) {
            $(mutation.addedNodes).find(place).each(function(i, container) {
                func(container, extraParams);
            });
        });
    });
    //run mutationobserver
    observer.observe(document.querySelector('#u0_1'), {
        childList: true
    });
}

//runs on all the images hahahaha
function redirect(img) {
    var link = img.parentNode;
    //imagemap case
    if (link.href.search(/^https?\:\/\/images/) == 0) {
        link.href = link.href.replace(/\/imap\//, '/img/');
    }
    //direct links case
    //lmao even if you have direct links on, avatars still point to the imagemap. lg pls
    else {
        link.href = link.href.replace(/i\d\./, 'images.').replace(/\/i\/[nt]\//, '/img/');
    }
}

//this should mess with images before they load
//only compatible with imagenorator version 3.1+
livelinks(redirect, null, 'span.img-placeholder');