Guest User

tt for endchan

a guest
Aug 23rd, 2020
1,211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. // ==UserScript==
  2. // @name TT for endchan
  3. // @version 1
  4. // @description Adds quick TT button for endchan
  5. // @author (You)
  6. // @match https://endchan.net/bbg/*
  7. // @grant none
  8. // @icon https://2chen.org/assets/favicons/default.ico
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. function render() {
  15. var i, href, match, articles = document.querySelectorAll('.originalNameLink:not(.ttFinalised)');
  16. if (!articles) return;
  17.  
  18. for(i = 0; i < articles.length; i++) {
  19. if (match = articles[i].parentNode.innerHTML.match(/6\d{18}/g)) {
  20. href = document.createElement("a"); href.target = "_blank";
  21. href.href = `https://www.tiktok.com/share/video/${match[0]}`;
  22. href.innerHTML = "<br/>» TikTok «";
  23.  
  24. articles[i]
  25. .parentNode
  26. .appendChild(href);
  27. }
  28.  
  29. articles[i].classList.add("ttFinalised");
  30. }
  31. }
  32.  
  33.  
  34. const root = document.getElementById("divThreads");
  35. const threadObserver = new MutationObserver(render);
  36. render();
  37.  
  38. threadObserver.observe(root, {
  39. childList: true,
  40. subtree: true,
  41. attributes: false
  42. });
  43.  
  44. })();
Add Comment
Please, Sign In to add comment