Advertisement
Zalati

Discord Youtube SelfBot status

Oct 21st, 2018
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function() {
  2.     'use strict';
  3.  
  4.     var interval = 60000;
  5.  
  6.     if( window.location.href.indexOf("youtube") > -1 ){
  7.         $.docReady = function(data) {
  8.             return $( document).ready(data);
  9.         };
  10.  
  11.         $.getTitle = function(){
  12.             return document.title;
  13.         };
  14.     }
  15.  
  16.     function urlToEpisode(url){
  17.         return '';
  18.     }
  19.  
  20.     $.docReady(function (){
  21.         var token = '';
  22.  
  23.         if(GM_getValue('token', 0)){
  24.             token = GM_getValue('token');
  25.         }else{
  26.             token = prompt("Entre le token de connexion.\nRegardez la description si besoin");
  27.             GM_setValue('token', token);
  28.         }
  29.  
  30.         var client = new Discord.Client({
  31.             token: token,
  32.             autorun: true
  33.         });
  34.  
  35.         client.on('ready', function() {
  36.             console.log("%s (%s)... in the browser!", client.username, client.id);
  37.             GM_deleteValue('timeLeft');
  38.             setInterval(function(){ setgame(); }, interval);
  39.             setgame();
  40.         });
  41.  
  42.         client.on('disconnect', function(errMsg, code) {
  43.             alert(errMsg);
  44.             if(code == 4004){
  45.                 GM_deleteValue('token');
  46.             }
  47.         });
  48.  
  49.         function setgame() {
  50.             var timeLeft = '';
  51.             if( typeof $('video').get(0) != 'undefined' ){
  52.                 var duration = $('video').get(0).duration;
  53.                 var current = $('video').get(0).currentTime;
  54.                 timeLeft =  Math.ceil((duration - current) / 60);
  55.                 if(timeLeft == null || timeLeft == 0 || isNaN(timeLeft)){
  56.                     timeLeft = '';
  57.                 }else{
  58.                     timeLeft = "( -"+timeLeft+" Min )";
  59.                 }
  60.             }
  61.  
  62.             if( timeLeft == '' && GM_getValue('timeLeft', '') != ''){
  63.                 timeLeft = GM_getValue('timeLeft', '');
  64.                 GM_deleteValue('timeLeft');
  65.             }
  66.  
  67.             var episode = urlToEpisode(window.location.href);
  68.             if(episode == null || episode == 0 || isNaN(episode)){
  69.                 episode = '';
  70.             }else{
  71.                 episode = 'Ep. '+ episode;
  72.             }
  73.             client.setPresence({
  74.                 game:{
  75.                     name: $.getTitle() +" "+ episode +" "+ timeLeft ,
  76.                     type: 3
  77.                 }
  78.             });
  79.             console.log('Set Game', $.getTitle() +" "+ episode +" "+ timeLeft);
  80.         }
  81.  
  82.         $( window ).unload(function() {
  83.             client.setPresence({ game:{ name:"", } });
  84.         });
  85.     });
  86. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement