🏠 Home 

AO3: Display Tag ID

a quick and dirty script to display a canonical tag's tag id in its /works page.


Install this script?
  1. // ==UserScript==
  2. // @name AO3: Display Tag ID
  3. // @namespace adustyspectacle
  4. // @description a quick and dirty script to display a canonical tag's tag id in its /works page.
  5. // @version 1.3
  6. // @history 1.3 - changed how the tag id's displayed
  7. // @history 1.2 - updated include urls to work with ao3's https switch
  8. // @history 1.1 - changed the include to be more specific
  9. // @grant none
  10. // @include http://*archiveofourown.org/tags/*/works
  11. // @include https://*archiveofourown.org/tags/*/works
  12. // @include http://*archiveofourown.org/works?*
  13. // @include https://*archiveofourown.org/works?*
  14. // ==/UserScript==
  15. function insertAfter(el, referenceNode) {
  16. referenceNode.parentNode.insertBefore(el, referenceNode.nextSibling);
  17. }
  18. // this bit checks whether someone is logged in or not. Logged out users will only see tag ids
  19. // for those with RSS feeds, i.e. fandoms, characters, and relationships. Logged in users will
  20. // also see those, plus additional tags, ratings, categories, and warnings.
  21. var log_status = document.getElementsByTagName('body')[0].getAttribute('class');
  22. if (log_status.startsWith('logged-out')) {
  23. var tag_id = document.getElementsByClassName('rss')[0].getAttribute('href').slice(6,-10);
  24. } else
  25. var tag_id = document.getElementById('favorite_tag_tag_id').getAttribute('value');
  26. // this bit is where the creation of the tag id element happens.
  27. var tag_id_container = document.createElement('span');
  28. tag_id_container.setAttribute('id', 'tag_id');
  29. tag_id_container.innerHTML = "Include: <strong>filter_ids:" + tag_id + "</strong><br/>Exclude: <strong>-filter_ids:" + tag_id + "</strong>";
  30. tag_id_container.style['vertical-align'] = '-0.3em';
  31. tag_id_container.style['display'] = 'inline-block';
  32. tag_id_container.style['margin-left'] = '0.5em';
  33. insertAfter(tag_id_container, document.querySelector('h2.heading'));