【发布时间】:2019-01-25 20:40:24
【问题描述】:
作为rollout of new network site themes 的一部分,我经常访问的许多 Stack Exchange 网站现在都有links in posts and comments underlined。
更喜欢无下划线的外观,并且由于我主要使用 Chrome(68.0.3440.106(官方构建)(64 位))和 Edge(42.17692.1004.0),它们似乎没有全局覆盖设置,所以我安装了Tampermonkey 并基于an example I found on Stack Apps 编写了一个小用户脚本,以及我通过搜索此站点找到的一些相关代码以寻求解决方案:
// ==UserScript==
// @name Remove link underlines on Stack Exchange
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match *://*.stackexchange.com/*
// @match *://*.stackoverflow.com/*
// @match *://*.mathoverflow.com/*
// @match *://*.serverfault.com/*
// @match *://*.superuser.com/*
// @match *://*.stackapps.com/*
// @match *://*.askubuntu.com/*
// @grant none
// @run-at document-body
// ==/UserScript==
(function() {
'use strict';
// Your code here...
var style = document.createElement("style");
style.appendChild(document.createTextNode("a {text-decoration: none !important;}"));
document.head.appendChild(style);
})();
这似乎基本上工作得很好,虽然我确实注意到有时在页面加载时有简短的链接下划线,然后它被替换为无下划线的外观。
我可以做些什么来让我喜欢的外观更直接地出现,而不会出现短暂的下划线?
我尝试了// @run-at document-start,它消除了闪烁,但有时这根本无法应用样式更改。
除了编写第一个用户脚本之外,我没有这方面的经验,所以请解释任何提议的更改的好处和风险。
我选择(并标记)Tampermonkey 是为了与我选择的浏览器兼容,并使我能够在将来运行其他用户脚本(包括不限于样式更改的脚本)。
【问题讨论】:
标签: css google-chrome microsoft-edge userscripts tampermonkey