Greasy Fork is available in English.

煎蛋无聊图图片加载加速

通过百度图片搜索功能中转无聊图实现快速加载。

< Feedback em 煎蛋无聊图图片加载加速

Pergunta/comentário

§
Publicado: 20/02/2024

更新了一下,自用还可以

// ==UserScript==
// @name         煎蛋无聊图图片加载加速
// @version      1.2
// @description  通过百度图片搜索功能中转无聊图实现快速加载。
// @author       丧心病狂的章鱼夫
// @license      MIT
// @match        https://*.jandan.net/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=jandan.net
// @grant        none
// @run-at       document-start
// @namespace   https://greasyfork.org/users/1028216
// ==/UserScript==

var proxy = 'https://i3.wp.com/lz.sinaimg.cn/oslarge/';

var accelerateImg = function() {
    // 替换图片链接
    var img = document.getElementsByTagName('img');
    for(var i=0;i<img.length;i++){
        if(!img[i].src.includes('moyu.im')) continue;
        img[i].src = img[i].src.replace(/(.*)moyu.im.*\/(.+)$/g, proxy + '$2');
        if(img[i].getAttribute("org_src") != null)
        {
            img[i].setAttribute("org_src", img[i].getAttribute("org_src").replace(/(.*)moyu.im.*\/(.+)$/g, proxy + '$2'));
        }
    }

    // 替换查看原图链接
    var link = document.getElementsByClassName("view_img_link");
    for(var i=0;i<link.length;i++){
        if(link[i].getAttribute("href") != null)
        {
            link[i].setAttribute("href", link[i].getAttribute("href").replace(/(.*)moyu.im.*\/(.+)$/g, proxy + '$2'));
        }
    }
};

if (
    document.readyState === "complete" ||
    (document.readyState !== "loading" && !document.documentElement.doScroll)
) {
    accelerateImg();
} else {
    document.addEventListener("DOMContentLoaded", accelerateImg);
}

Publicar resposta

Faça o login para publicar uma resposta.