TEXT   38   0
   151 1.42 KB    41

Untitled

By cenodis
Created: 2023-01-04 01:10:43
Updated: 2023-01-05 19:20:01
Expiry: Never

  1. 1.
    // ==UserScript==
  2. 2.
    // @name Thread extraction
  3. 3.
    // @namespace http://tampermonkey.net/
  4. 4.
    // @version 0.1
  5. 5.
    // @author You
  6. 6.
    // @description A script to scrape thread IDs from wayback captures of anonpone
  7. 7.
  8. 8.
    // @grant GM_setClipboard
  9. 9.
    // ==/UserScript==
  10. 10.
     
  11. 11.
    (function() {
  12. 12.
    'use strict';
  13. 13.
    var btn = document.createElement("button");
  14. 14.
    btn.textContent = "Export threads to clip";
  15. 15.
    btn.className = "btn btn-default";
  16. 16.
    btn.onclick = () => {
  17. 17.
    var button = Array.from(document.getElementsByClassName("btn")).find(e => e.textContent.trim() === 'Threads');
  18. 18.
     
  19. 19.
    if (button == null) {
  20. 20.
    console.log("No thread menu found");
  21. 21.
    return;
  22. 22.
    }
  23. 23.
     
  24. 24.
    var thread_menu = button.parentNode.getElementsByTagName("ul")[0];
  25. 25.
     
  26. 26.
    var threads = Array.from(thread_menu.getElementsByTagName("li"));
  27. 27.
    var clip = new Array();
  28. 28.
    clip.push(document.title);
  29. 29.
     
  30. 30.
    for(var i = 0; i < threads.length; i++) {
  31. 31.
    var text = threads[i].textContent.match(/\d+/)[0];
  32. 32.
    clip.push("\t" + text);
  33. 33.
    }
  34. 34.
     
  35. 35.
    GM.setClipboard(clip.join('\n') + '\n');
  36. 36.
    btn.textContent = "Copied";
  37. 37.
    }
  38. 38.
     
  39. 39.
    var button_group = Array.from(document.getElementsByTagName("button")).find(e => e.textContent.trim() === 'Threads').parentNode.parentNode;
  40. 40.
    button_group.appendChild(btn);
  41. 41.
    })();