怀旧/多样化图标,根据个人喜好

使用此油猴脚本,将会把L站替换为你自己喜欢的图标。

(已更新)

// ==UserScript==
// @name         小企鹅回来吧!
// @namespace    http://tampermonkey.net/
// @version      0.3
// @description  Replace the favicon and specified images of Linux.do with custom icons
// @author       Marks
// @match        https://linux.do/*
// @icon         https://cdn3.linux.do/optimized/1X/3a18b4b0da3e8cf96f7eea15241c3d251f28a39b_2_180x180.png
// @grant        none
// @run-at       document-start
// ==/UserScript==

(function() {
    'use strict';

    const iconUrl = 'https://cdn3.linux.do/optimized/1X/3a18b4b0da3e8cf96f7eea15241c3d251f28a39b_2_180x180.png'; // 默认是老版企鹅,也可以替换成你的图标链接
    const titleUrl = 'https://cdn3.linux.do/original/1X/3384bfa75bc9b118cc47fbf4fd96cdcde4a2a501.png';
    const imagePattern = /^https:\/\/cdn\.linux\.do\/uploads\/default\/original\/.+/;

    function replaceFavicon() {
        const favicon = document.createElement('link');
        favicon.rel = 'icon';
        favicon.href = iconUrl;
        favicon.type = 'image/png'; // 根据实际图标类型调整

        const existingFavicon = document.querySelector('link[rel="icon"], link[rel="shortcut icon"]');
        if (existingFavicon) {
            document.head.removeChild(existingFavicon);
        }
        document.head.appendChild(favicon);

        new MutationObserver((mutations, observer) => {
            mutations.forEach((mutation) => {
                if (mutation.type === 'childList' && mutation.addedNodes.length > 0) {
                    mutation.addedNodes.forEach(node => {
                        if (node.rel === 'icon' || node.rel === 'shortcut icon') {
                            node.href = iconUrl;
                        }
                    });
                }
            });
        }).observe(document.head, { childList: true, subtree: true });
    }

    function replaceImages() {
        const images = document.querySelectorAll('img');
        images.forEach(img => {
            if (imagePattern.test(img.src)) {
                img.src = iconUrl;
            }
        });
    }

    function observeImages() {
        const observer = new MutationObserver((mutations, observer) => {
            mutations.forEach(mutation => {
                if (mutation.type === 'childList' && mutation.addedNodes.length > 0) {
                    mutation.addedNodes.forEach(node => {
                        if (node.nodeType === Node.ELEMENT_NODE) {
                            if (node.tagName === 'IMG' && imagePattern.test(node.src)) {
                                node.src = iconUrl;
                            } else {
                                const descendantImages = node.querySelectorAll('img');
                                descendantImages.forEach(img => {
                                    if (imagePattern.test(img.src)) {
                                        img.src = iconUrl;
                                    }
                                });
                            }
                        }
                    });
                }
            });
        });

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

    replaceFavicon();
    replaceImages();
    observeImages();
})();

16 个赞

:tieba_013:

2 个赞

good!这就换掉

1 个赞

我坚定支持始皇,只是比较恋旧罢了。。始皇别杀我

9 个赞

哇,马老师已经写好了,太好了

2 个赞

谢谢你 马克思

1 个赞

油猴里塞满了linux.do的脚本 :laughing:

2 个赞

Thanks, but I like changes.

1 个赞

喜欢此logo的可以去此贴下载,始皇认可的logo!


4 个赞

安卓鸭鸭怎么开脚本?被始皇的自嗨恶心到了

1 个赞

安卓鸭鸭是什么?

3 个赞

这就试试

1 个赞

安卓鸡

1 个赞

好像via浏览器可以油猴吧,好久没用过安卓了

1 个赞

:call_me_hand:t6: :+1:t6:

big胆,始皇激情了几天的成果你一下就打回了

4 个赞

果然大家是对 logo 有自己的想法

感谢,已经换上了

这个logo的链接是啥啊