ETI Image Redirector

changes images from linking to their imagemap to their image page

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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');