AO3: [Wrangling] Lazy Click!

Clicking anywhere in the tag name's box selects that tag!

  1. // ==UserScript==
  2. // @name AO3: [Wrangling] Lazy Click!
  3. // @description Clicking anywhere in the tag name's box selects that tag!
  4. // @version 1.0.1
  5.  
  6. // @author owlwinter
  7. // @namespace N/A
  8. // @license MIT license
  9.  
  10. // @match *://*.archiveofourown.org/tags/*/wrangle*
  11. // @grant none
  12. // ==/UserScript==
  13.  
  14.  
  15. (function() {
  16. 'use strict';
  17.  
  18. const tbody = document.getElementById("wrangulator").getElementsByTagName("tbody")[0]
  19. tbody.addEventListener("click", (e) => {
  20. if (!e.srcElement) return;
  21. let f = e.srcElement
  22. while (f) {
  23. if (f.tagName == "TH") {
  24. //Selects the check box
  25. const cbox = f.querySelector("input")
  26. cbox.checked = !cbox.checked
  27. return
  28. }
  29. //Cases where the user actually did click the tag's checkbox or text
  30. if (f.tagName == "INPUT" || f.tagName == "LABEL") {
  31. return
  32. }
  33. f = f.parentElement;
  34. }
  35. });
  36. })();