[AO3] Bookmark links

Create a bookmark link button at the bottom of every bookmark full blurb

  1. // ==UserScript==
  2. // @name [AO3] Bookmark links
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description Create a bookmark link button at the bottom of every bookmark full blurb
  6. // @grant none
  7. // @license MIT
  8. // @match *://*.archiveofourown.org/*
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. if (window.location.href.match('/users/') && document.querySelectorAll('li.bookmark.blurb').length) {
  15. for (const b of document.querySelectorAll('li.bookmark.blurb')) {
  16. if (!b.querySelectorAll('.actions[role="navigation"]').length) {
  17. let ul = document.createElement('ul')
  18. ul.className = 'actions'
  19. ul.setAttribute('role','navigation')
  20. b.appendChild(ul)
  21. }
  22.  
  23. let ul = b.querySelector('.actions[role="navigation"]'),
  24. li = document.createElement('li'),
  25. a = document.createElement('a')
  26.  
  27. a.textContent = 'Link'
  28. a.href = '/bookmarks/' + b.id.split('_')[1]
  29.  
  30. li.appendChild(a)
  31. ul.appendChild(li)
  32. b.appendChild(ul)
  33. }
  34. }
  35. })();