使用此油猴脚本,将会把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();
})();



