highlight_anchor_target

if url contains a target, the anchor in the site will be highlighted

  1. // ==UserScript==
  2. // @name highlight_anchor_target
  3. // @namespace https://greasyfork.org/de/users/157797-lual
  4. // @match *://*/*
  5. // @version 1.0
  6. // @description if url contains a target, the anchor in the site will be highlighted
  7. // @author lual
  8. // @grant GM_addStyle
  9. // @icon data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="50" cy="50" r="48" fill="%2378F48F" stroke="%231B6329" stroke-width="2" /> <text x="50" y="50" font-family="Arial, sans-serif" font-size="90" fill="%23000000" text-anchor="middle" dominant-baseline="central">%23</text></svg>
  10. // ==/UserScript==
  11. //
  12. // Some URIs refer to a location within a document.
  13. // This kind of URI ends with "#" followed by an anchor identifier (called the fragment identifier).
  14. // This script will highligt the anchor in the document.
  15. //
  16. // For fundamentals and as an example for using this script - see...
  17. // http://www.w3.org/TR/html401/intro/intro.html#fragment-uri
  18. //
  19. //
  20. // changes: 2011-03-17 initial
  21. // 2017-11-01 publish on greasyfork
  22. // 2022-11-10 convert deprecated @include to @match
  23. // 2024-10-16 improve @match
  24. /////////////////////////////////////////////////////////////////////////////////////////////////////////
  25. if (document.contentType === 'text/html') {
  26. // Proceed with the script only for HTML content (ignore XML, JSON, etc.)
  27. (function() {
  28. 'use strict';
  29. GM_addStyle(`
  30. :target {
  31. color: black !important;
  32. background-color: #78F48F !important;
  33. border: 1px solid #27A53F !important;
  34. border-bottom: 1px solid #1B6329 !important;
  35. border-right: 1px solid #1B6329 !important;
  36. border-radius: 3px;
  37. }`);
  38.  
  39. })();
  40. }