您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Display the URLs of external links.
当前为
- // ==UserScript==
- // @name display-external-urls
- // @namespace https://github.com/ahuanguchi
- // @version 1.0.2
- // @description Display the URLs of external links.
- // @author ahuanguchi
- // @match *://*/*
- // @grant none
- // @run-at document-start
- // ==/UserScript==
- window.addEventListener("load", function () {
- function splitHref(givenHref) {
- return givenHref.replace(/^https?:\/\//, "").split("/");
- }
- var i, currentA, currentHref, anchorParts, locationParts;
- var anchors = document.getElementsByTagName("a");
- var numAnchors = anchors.length;
- for (i = 0; i < numAnchors; i += 1) {
- currentA = anchors[i];
- currentHref = currentA.href;
- anchorParts = splitHref(currentHref);
- locationParts = splitHref(window.location.href);
- if (currentHref.slice(0, 4) === "http" && anchorParts[0] !== locationParts[0]) {
- currentA.innerHTML = currentA.innerHTML + "<small> (<u>" + currentHref + "</u>)</small>";
- }
- }
- });