Wikipedia - Linkify headers

An userscript helping you get the url linking to specified section

  1. // ==UserScript==
  2. // @name Wikipedia - Linkify headers
  3. // @version 0.1.1
  4. // @namespace eight04.blogspot.com
  5. // @description An userscript helping you get the url linking to specified section
  6. // @include https://*wikipedia.org/*
  7. // @grant GM_addStyle
  8. // @compatible firefox
  9. // @compatible chrome
  10. // @compatible opera
  11. // ==/UserScript==
  12.  
  13. "use strict";
  14.  
  15. var nodes = document.querySelectorAll("#mw-content-text span.mw-headline[id]"),
  16. i, link;
  17.  
  18. for (i = 0; i < nodes.length; i++) {
  19. link = document.createElement("a");
  20. link.innerHTML = "&#128279;";
  21. link.href = "#" + nodes[i].id;
  22. link.className = "mw-headline-link";
  23. nodes[i].appendChild(link);
  24. }
  25.  
  26. GM_addStyle(".mw-headline-link{font-size:70%;margin-left:.2em;display:none}.mw-headline:hover .mw-headline-link{display:inline}");

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址