Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*************************************************************
- *
- * Name: Saker.IT
- * Description: generate and display embed code for all videos
- * loaded in channel
- * Author: Unrez
- *
- * To the extent possible under law, Unrez has waived all
- * copyright and related or neighboring rights to Saker.IT.
- *
- * https://creativecommons.org/publicdomain/zero/1.0/
- *
- * NOTE: this only works for videos that have been
- * loaded in the browser. as you scroll up
- * more videos and posts will appear so you'll
- * need to click the bookmarklet again to fetch
- * the new embed codes. for any interested
- * developers this could be easily ported
- * to a chrome extension to execute the code
- * after each page loads or after the DOM
- * tree changes.
- *
- * TO CREATE BOOKMARKLET IN BRAVE:
- * 1. create a new bookmark on your toolbar for any page
- * 2. right click and edit the bookmark
- * 3. enter Saker.IT for the name
- * 4. copy/paste all the code below for the url
- * 5. visit any url in browser like https://t.me/s/SPUTNIK
- * 6. click the bookmarklet after page has loaded
- * 7. video embed code will appear in text box below each video
- *
- *************************************************************/
- javascript:function getEmbedCode(val) {
- return '<script async src="https://telegram.org/js/telegram-widget.js?18" data-telegram-post="' + val + '" data-width="100%"></script>';
- }
- function findVideos() {
- if (window.location.href.indexOf('/t.me/s/') < 0) return;
- var pnode,dtp,ta,tarea;
- var vids = document.getElementsByTagName('video');
- for (var i=0; i<vids.length; i++) {
- pnode = vids[i].parentNode;
- for (var j=0; j<3; j++) {
- if (pnode.nodeName.toLowerCase() == 'a') {
- dtp = pnode.href.match(/\/t.me\/([^?]+)/);
- if (dtp.length > 1 && dtp[1]) {
- ta = pnode.parentNode.getElementsByTagName('textarea');
- if (ta.length < 1) {
- tarea = document.createElement('textarea');
- tarea.appendChild(document.createTextNode(getEmbedCode(dtp[1])));
- tarea.style.fontSize = '10px';
- tarea.style.width = '100%';
- tarea.style.height = '35px';
- if (pnode.nextSibling) {
- pnode.parentNode.insertBefore(document.createElement('br'), pnode.nextSibling);
- pnode.parentNode.insertBefore(tarea, pnode.nextSibling);
- } else {
- pnode.parentNode.appendChild(document.createElement('br'));
- pnode.parentNode.appendChild(tarea);
- }
- }
- }
- break;
- }
- pnode = pnode.parentNode;
- }
- }
- }
- findVideos();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement