除去花里胡哨的,标明身份
更新:引入 MutationObserver,解决页面没有完全重新加载,脚本可能就不会运行的 bug
// ==UserScript==
// @name Enhanced CSS Styles on linux.do subpages and Replace User Title
// @namespace http://tampermonkey.net/
// @version 1.3
// @description Override specific CSS styles and add labels on linux.do subpages
// @author YourName
// @match https://linux.do/*
// @grant GM_addStyle
// ==/UserScript==
(function() {
'use strict';
// Function to replace user title
function replaceUserTitle() {
// Find all elements with the class 'user-title'
const userTitles = document.querySelectorAll('span.user-title');
// Iterate through all found elements
userTitles.forEach(function(userTitle) {
// Check if the text content matches "岂曰无衣?"
if (userTitle.textContent.trim() === "岂曰无衣?") {
// Replace the text content with "版主"
userTitle.textContent = "版主";
}
});
}
function applyStylesAndReplaceTitle() {
// Check if the current page is not the homepage
if (window.location.href !== "https://linux.do/") {
// Override the CSS by adding new rules
GM_addStyle(`
/* Override avatar styles */
div.topic-avatar .post-avatar a[data-user-card="neo"] img.avatar,
img.avatar[src="https://cdn.linux.do/user_avatar/linux.do/neo/288/12_2.png"],
div.user-card-neo img.avatar {
border: none !important;
box-shadow: none !important;
animation: none !important;
}
/* Update the "TOPIC OWNER" label to "楼主", set font style to normal, and set font-family to 微软雅黑 */
div.topic-owner .topic-body .contents>.cooked::after {
content: "楼主" !important; /* Updated text */
font-size: small !important;
color: #00aeff !important;
float: right !important;
font-style: normal !important; /* Set font style to normal with !important */
font-weight: 700 !important;
font-family: "微软雅黑", sans-serif !important; /* Set font-family to 微软雅黑 with !important */
}
/* Remove the keyframes animation */
@keyframes avatar-breathing-light {
0%, 100% {
box-shadow: none !important;
}
60% {
box-shadow: none !important;
}
}
`);
// Run the function to replace user titles
replaceUserTitle();
}
}
// Apply styles and replace user title initially
applyStylesAndReplaceTitle();
// Listen for changes in the URL
window.addEventListener('popstate', function(event) {
// When the URL changes, re-apply the styles and replace the user title
applyStylesAndReplaceTitle();
});
})();