Advertisement
Guest User

Saker.IT bookmarklet

a guest
Apr 2nd, 2022
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.66 KB | None | 0 0
  1. /*************************************************************
  2. *
  3. * Name: Saker.IT
  4. * Description: generate and display embed code for all videos
  5. * loaded in channel
  6. * Author: Unrez
  7. *
  8. * To the extent possible under law, Unrez has waived all
  9. * copyright and related or neighboring rights to Saker.IT.
  10. *
  11. * https://creativecommons.org/publicdomain/zero/1.0/
  12. *
  13. * NOTE: this only works for videos that have been
  14. * loaded in the browser. as you scroll up
  15. * more videos and posts will appear so you'll
  16. * need to click the bookmarklet again to fetch
  17. * the new embed codes. for any interested
  18. * developers this could be easily ported
  19. * to a chrome extension to execute the code
  20. * after each page loads or after the DOM
  21. * tree changes.
  22. *
  23. * TO CREATE BOOKMARKLET IN BRAVE:
  24. * 1. create a new bookmark on your toolbar for any page
  25. * 2. right click and edit the bookmark
  26. * 3. enter Saker.IT for the name
  27. * 4. copy/paste all the code below for the url
  28. * 5. visit any url in browser like https://t.me/s/SPUTNIK
  29. * 6. click the bookmarklet after page has loaded
  30. * 7. video embed code will appear in text box below each video
  31. *
  32. *************************************************************/
  33.  
  34. javascript:function getEmbedCode(val) {
  35. return '<script async src="https://telegram.org/js/telegram-widget.js?18" data-telegram-post="' + val + '" data-width="100%"></script>';
  36. }
  37.  
  38. function findVideos() {
  39. if (window.location.href.indexOf('/t.me/s/') < 0) return;
  40. var pnode,dtp,ta,tarea;
  41. var vids = document.getElementsByTagName('video');
  42. for (var i=0; i<vids.length; i++) {
  43. pnode = vids[i].parentNode;
  44. for (var j=0; j<3; j++) {
  45. if (pnode.nodeName.toLowerCase() == 'a') {
  46. dtp = pnode.href.match(/\/t.me\/([^?]+)/);
  47. if (dtp.length > 1 && dtp[1]) {
  48. ta = pnode.parentNode.getElementsByTagName('textarea');
  49. if (ta.length < 1) {
  50. tarea = document.createElement('textarea');
  51. tarea.appendChild(document.createTextNode(getEmbedCode(dtp[1])));
  52. tarea.style.fontSize = '10px';
  53. tarea.style.width = '100%';
  54. tarea.style.height = '35px';
  55. if (pnode.nextSibling) {
  56. pnode.parentNode.insertBefore(document.createElement('br'), pnode.nextSibling);
  57. pnode.parentNode.insertBefore(tarea, pnode.nextSibling);
  58. } else {
  59. pnode.parentNode.appendChild(document.createElement('br'));
  60. pnode.parentNode.appendChild(tarea);
  61. }
  62. }
  63. }
  64. break;
  65. }
  66. pnode = pnode.parentNode;
  67. }
  68. }
  69. }
  70.  
  71. findVideos();
  72.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement