Guest User

Untitled

a guest
Nov 21st, 2017
892
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         issoutv
  3. // @namespace    http://tampermonkey.net/
  4. // @version      0.1
  5. // @description  try to take over the world!
  6. // @author       ence
  7. // @match        https://avenoel.org/topic*
  8. // @grant        none
  9. // ==/UserScript==
  10.  
  11. function createIssoutvPlayer (id) {
  12.     const formats = ['webm', 'mp4'];
  13.  
  14.     let video = document.createElement('video');
  15.     video.setAttribute('controls', '');
  16.     video.setAttribute('width', '320');
  17.     video.setAttribute('height', '240');
  18.     video.setAttribute('preload', 'none');
  19.  
  20.     let sources = formats.map(format => {
  21.         let source1 = document.createElement('source');
  22.         let source2 = document.createElement('source');
  23.  
  24.         source1.setAttribute('src', `http://issoutv.com/files/${id}${format === 'mp4' ? '.mp4' : ''}`);
  25.         source2.setAttribute('src', `http://issoutv.com/filesSecond/${id}${format === 'mp4' ? '.mp4' : ''}`);
  26.         source1.setAttribute('type', `video/${format}`);
  27.         source2.setAttribute('type', `video/${format}`);
  28.  
  29.         video.appendChild(source1);
  30.         video.appendChild(source2);
  31.     });
  32.  
  33.     return video;
  34. }
  35.  
  36. function issoutv () {
  37.     Array.from(document.getElementsByClassName('message-content')).map(message => {
  38.             Array.from(message.getElementsByTagName('a'))
  39.             .filter(a => a.host === 'issoutv.com' && a.pathname === '/view.php')
  40.             .map(a => {
  41.                 let player = createIssoutvPlayer(a.search.split('=')[1]);
  42.                 a.parentNode.parentNode.replaceChild(player, a.parentNode);
  43.          });
  44.     });
  45. }
  46.  
  47. function createWebmPlayer (src) {
  48.     let video = document.createElement('video');
  49.     video.setAttribute('controls', '');
  50.     video.setAttribute('width', '320');
  51.     video.setAttribute('height', '240');
  52.     video.setAttribute('preload', 'none');
  53.  
  54.     let source = document.createElement('source');
  55.     source.setAttribute('src', src);
  56.     source.setAttribute('type', 'video/webm');
  57.  
  58.     video.appendChild(source);
  59.  
  60.     return video;
  61. }
  62.  
  63. function webm () {
  64.         Array.from(document.getElementsByClassName('message-content')).map(message => {
  65.             Array.from(message.getElementsByTagName('a'))
  66.             .filter(a => a.pathname.split('.').pop() === 'webm')
  67.             .map(a => {
  68.                 let player = createWebmPlayer(a.href);
  69.                 a.parentNode.parentNode.replaceChild(player, a.parentNode);
  70.          });
  71.     });
  72. }
  73.  
  74. (function() {
  75.     'use strict';
  76.  
  77.     issoutv();
  78.     webm();
  79. })();
Advertisement
Add Comment
Please, Sign In to add comment