Guest User

Untitled

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