B1uscr34m

iloveradio.user.js

May 6th, 2016
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         ILoveRadioBot
  3. // @namespace    http://tampermonkey.net/
  4. // @version      0.1
  5. // @description  try to take over the world!
  6. // @author       Bluscream
  7. // @updateurl    https://gist.github.com/Bluscream/d0f3bf4f4e380e528cb60f51aafc28c7/raw/1269e890147dc1885f34da8e813cd803328b7974/iloveradio.user.js
  8. // @match        http://www.iloveradio.de/*
  9. // @grant        none
  10. // ==/UserScript==
  11. var interval;
  12. (function() {
  13.     'use strict';
  14.     var sendMessage = function(msg){ ilr3.shoutbox.send(msg);};
  15.     var sayMessage = function(name, msg){ sendMessage(name+': '+msg);};
  16.     var ilr = {
  17.         name: 'BluBoot',
  18.         admins: ['Bluscream', 'Angi'],
  19.         prefix: '!',
  20.         welcomes: ['hi', 'hey', 'hallo', 'jo', 'hallöchen'],
  21.         byes: ['bye', 'tschüss', 'tschau', 'ciao'],
  22.         users: [],
  23.         blacklist: [],
  24.         commands: {
  25.             'help': 'var coms = "";'+
  26.                 'for (var key in ilr.commands) {'+
  27.                     'if (!ilr.commands.hasOwnProperty(key)){continue;}'+
  28.                     'if (ilr.admincommands.hasOwnProperty(key)){continue;}'+
  29.                     'coms = coms + ilr.prefix +key+" ";'+
  30.                 '}'+
  31.                 'ilr3.shoutbox.send('+
  32.                 '"Commands: "+coms);',
  33.             'boot': 'ilr3.shoutbox.send("gist[DOT]github[DOT]com/Bluscream/d0f3bf4f4e380e528cb60f51aafc28c7");',
  34.             'playing': 'var _radio = $(".channel-headline.big").text();'+
  35.             'var _artist = $(".channelinfo>.artist").text().toTitleCase();'+
  36.             'var _title = $(".channelinfo>.title").text().toTitleCase();'+
  37.                 'ilr3.shoutbox.send(_radio+" is playing \'"+_title+"\' by \'"+_artist+"\'.");',
  38.             'time': 'var _now = new Date();ilr3.shoutbox.send(_now.toString());',
  39.             'last': 'ilr3.shoutbox.send("UPPER: \'"+lastMessage.name.toUpperCase()+"\' lower: \'"+lastMessage.name.toLowerCase()+"\'");',
  40.             'love': 'switch(args.length){'+
  41.                 'case 1:'+
  42.                     'ilr3.shoutbox.send(msg.name+" ♥ "+args[0]);break;'+
  43.                 'case 2:'+
  44.                     'ilr3.shoutbox.send(args[0]+" ♥ "+args[1]);break;'+
  45.             '};',
  46.             'credits': 'ilr3.shoutbox.send("Thanks to Angi, FaridBang and Rooz.");',
  47.             'info': 'ilr3.shoutbox.send("Boot written as ECMS Java Userscrlpt by Bluscream with ♥");',
  48.             'calc': 'if(args.length == 3){var result = 0;switch(args[1]){'+
  49.                 'case "+": result = Number(args[0]) + Number(args[2]);break;'+
  50.                 'case "-": result = Number(args[0]) - Number(args[2]);break;'+
  51.                 'case "*": result = args[0] * args[2];break;'+
  52.                 'case "/": args[1] = "/";result = args[0] / args[2];break;'+
  53.             '};'+
  54.             'sayMessage(msg.name, args[0]+" "+args[1]+" "+args[2]+" = "+result)};',
  55.             'uinfo': 'var _user = args.toString().replaceAll(","," ");'+
  56.                 'var _name = "unknown";var _id = "unknown";'+
  57.                 'var _users = ilr.users;'+
  58.                 'var _length = _users.length;'+
  59.                 'for (var i = 0; i < _length; i++) {'+
  60.                     'if(_users[i] == _user){'+
  61.                         'sendMessage("ID: "+i+" Name: \'"+_users[i]+"\' lower: \'"+_users[i].toLowerCase()+"\' UPPER: \'"+_users[i].toUpperCase()+"\'");break;'+
  62.                     '}'+
  63.                 '};',
  64.             'uid': 'console.info(ilr.getUserByID(Number(args[0])));',
  65.             'ulist': 'sendMessage(ilr.users.toString());',
  66.             'ulength': 'sendMessage("User Database contains "+ilr.users.length.toString()+" users.");',
  67.             'angi': 'sendMessage("♥ Angi isch kuhl oke ♥");',
  68.             'jessi': 'sendMessage("♥ Jessi is love, Jessi is life! ♥");',
  69.             'contact': 'sendMessage("Steam/Github: Bluscream");',
  70.         },
  71.         admincommands: {
  72.             'blist': 'ilr3.shoutbox.send("Blacklisted Users: "+ilr.blacklist.toString());',
  73.             'blacklist': 'ilr.blacklist.push(args.toString().replaceAll(","," "));saveSettings("blacklist", ilr.blacklist);ilr3.shoutbox.send(args.toString().replaceAll(","," ")+" was blacklisted by "+msg.name+".");',
  74.             'unblacklist': 'ilr.blacklist.splice(ilr.blacklist.indexOf(args.toString().replaceAll(","," ")), 1);saveSettings("blacklist", ilr.blacklist);ilr.blacklist.push(msg.name);ilr3.shoutbox.send(args.toString().replaceAll(","," ")+" was un-blacklisted by "+msg.name+".");',
  75.             'repeat': 'if(args.length > 1){var _delay = Number(args[0])*1000;var _args = args; _args.shift();interval = setInterval(function(){ilr3.shoutbox.send(_args.toString().replaceAll(","," "));}, _delay)};',
  76.             'srepeat': 'clearInterval(interval);',
  77.             'eval': 'eval(args.toString().replaceAll(","," "));ilr3.shoutbox.send(" Executed: "+args.toString().replaceAll(","," "));',
  78.             'say': 'ilr3.shoutbox.send(msg.name+" says \\""+args.toString().replaceAll(","," ")+"\\".");',
  79.             'restart': 'ilr3.shoutbox.send("Boot is restarting...");window.location.reload();',
  80.             'ban': 'ilr3.shoutbox.send(args.toString().replaceAll(","," ")+" was banned by "+msg.name+".");',
  81.             'mute': 'ilr3.shoutbox.send(args.toString().replaceAll(","," ")+" was muted by "+msg.name+".");',
  82.         },
  83.         getUserByName: function(name){
  84.             $.each(ilr.users, function(i,e){
  85.                 if(e == name){return {'id': i, 'name': e, 'lower': e.toLowerCase(), 'upper': e.toUpperCase()};}
  86.             }
  87.         );},
  88.         getUserByID: function(id){
  89.             $.each(ilr.users, function(i,e){
  90.                 if(i == id){return {'id': i, 'name': e, 'lower': e.toLowerCase(), 'upper': e.toUpperCase()};}
  91.             }
  92.         );}
  93.     };
  94.     ilr.welcome = 'logged in. Use '+ilr.prefix+'help to get a list of Commands.';
  95. //  'String'.capitalizeFirstLetter();
  96.     String.prototype.capitalizeFirstLetter = function() {
  97.         return this.charAt(0).toUpperCase() + this.slice(1);
  98.     };
  99. //  'String'.toTitleCase();
  100.     String.prototype.toTitleCase = function() {
  101.     return this.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
  102.     };
  103. //  'String'.contains(str);
  104.     String.prototype.contains = function(str) {
  105.         return this.indexOf(str) != -1;
  106.     };
  107. //  'String'.replaceAll(search, replacement);
  108.     String.prototype.replaceAll = function(search, replacement) {
  109.         return this.split(search).join(replacement);
  110.     };
  111. //  isEmpty(s);
  112.     var isEmpty = function(s) {
  113.         if( !s || (typeof s === "undefined") || (typeof s === null) || (s == "null") || (s == "undefined") || (s == "empty") || (s == "NaN") || (s == "-1")){
  114.             return true;
  115.         }else{
  116.             return false;
  117.         }
  118.     };
  119. //  loadSettings(name, default, base64);
  120.     var loadSettings = function(name, settings, base64){
  121.         if(base64){
  122.             if (isEmpty(localStorage.getItem(name))){ localStorage.setItem(name, btoa(JSON.stringify(settings))); }
  123.             name = window.localStorage[name];return JSON.parse(atob(name));
  124.         }else{
  125.             if (isEmpty(localStorage.getItem(name))){ localStorage.setItem(name, JSON.stringify(settings)); }
  126.             return JSON.parse(localStorage.getItem(name));
  127.         }
  128.     };
  129. //  saveSettings(name, settings, base64);
  130.     var saveSettings = function(name, settings, base64){
  131.         if(base64){
  132.             localStorage.setItem(name, btoa(JSON.stringify(settings)));
  133.         }else{
  134.             localStorage.setItem(name,JSON.stringify(settings));
  135.         }
  136.     };
  137.     ilr.blacklist = loadSettings("blacklist", ilr.blacklist);
  138.     var lastMessage = "";
  139.     setTimeout(function(){
  140.         $('#playstop').click();
  141.         localStorage.removeItem('ilr_uid');
  142.         ilr3.log = function(){};
  143.         $('#ilr_shoutbox .chat .msg').unbind('keyup').bind('keyup', function(e) {
  144.             if (e.keyCode === 13) {
  145.                 ilr3.shoutbox.send($('#ilr_shoutbox .chat .msg').val());
  146.                 $('#ilr_shoutbox .chat .msg').val('');
  147.             }
  148.         });
  149.         ilr3.shoutbox.get = function(msg) {
  150.             console.log(msg);
  151.             msg.name = decodeURI(msg.name);
  152.             msg.text = decodeURI(msg.text);
  153.             var text = msg.text;
  154.             var _text = text.toLowerCase();
  155.             var _users = ilr.users;
  156.             if(msg.name == ilr.name){
  157.                 if(typeof msg.verified === 'undefined'){
  158.                     msg.verified = true;
  159.                 }
  160.             }
  161.             if (('undefined' !== typeof msg.verified)) {
  162.                 $('#ilr_shoutbox .chat .textarea').append('<div><span class="name">' + msg.name + ((msg.verified === true) ? '<span class="verified"></span>' : '') + '</span>' + msg.text + '</div>');
  163.             } else {
  164.                 $('#ilr_shoutbox .chat .textarea').append('<div><span class="name">' + msg.name + '</span>' + msg.text + '</div>');
  165.             }
  166.             while ($('#ilr_shoutbox .chat .textarea div').length > 50) {
  167.                 $('#ilr_shoutbox .chat .textarea div:first').remove();
  168.             }
  169.             if ($('#ilr_shoutbox .chat .textarea').length > 0) {
  170.                 $('#ilr_shoutbox .chat .textarea').scrollTop($('#ilr_shoutbox .chat .textarea')[0].scrollHeight);
  171.             }
  172.             if(msg.name != ilr.name){
  173.                 //console.info($.inArray( _users, msg.name ));
  174.                 if($.inArray( msg.name, _users ) == -1){
  175.                     if(msg.name.contains('I')){
  176.                         $.each(ilr.users, function(i,e){
  177.                             if(e == msg.name.replaceAll('I', 'l') && msg.name != e){
  178.                                 ilr3.shoutbox.send('\''+msg.name.toLowerCase()+'\'s name contains a uppercase "i", he\'s probably faking '+msg.name.replaceAll('I', 'l')+'.');return;
  179.                             }
  180.                         });
  181.                     }else{
  182.                         var _length = ilr.welcomes.length;
  183.                         for (var i = 0; i < _length; i++) {
  184.                             if(_text.contains(ilr.welcomes[i])){
  185.                                 ilr3.shoutbox.send('Hey '+msg.name+' ♥');
  186.                             }
  187.                         }
  188.                 }
  189.                     _users.push(msg.name);
  190.                 }
  191.                 //$.each( ilr.byes, function(i,e){
  192.                     //if(_text.contains(e)){
  193.                         //ilr3.shoutbox.send('Bye '+msg.name+' ☻');
  194.                     //}
  195.                 //});
  196.                 // console.log(ilr.users);
  197.             }
  198.             if(_text.startsWith(ilr.prefix)){
  199.                 if($.inArray(msg.name, ilr.blacklist) != -1){return;};
  200.                 var _txt = text.split(ilr.prefix)[1];
  201.                 var args = _txt.split(' ') || '';
  202.                 var cmd = args.shift();
  203.                 for (var key in ilr.commands) {
  204.                     if (!ilr.commands.hasOwnProperty(key)) continue;
  205.                     var command = key.toLowerCase();
  206.                     var action = ilr.commands[key];
  207.                     if(cmd == command){
  208.                         console.info('Command \''+cmd+'\' with arguments \''+args+'\' was issued by '+msg.name+'.');
  209.                         try{
  210.                             if(msg.name == ilr.name){
  211.                                 setTimeout(function(){eval(action);}, 1000);break;
  212.                             }else{
  213.                                 eval(action);break;
  214.                             }
  215.                         }catch(e){
  216.                             sayMessage(msg.name, '\''+command+'\' '+e);
  217.                             console.error('Bot is unable to process command '+command+'\n\n.Error Message: '+e+'\n\nAction:\n\n'+action);break;
  218.                         }
  219.                     }
  220.                 }
  221.                 for (var key in ilr.admincommands) {
  222.                     if (!ilr.admincommands.hasOwnProperty(key)) continue;
  223.                     var command = key.toLowerCase();
  224.                     var action = ilr.admincommands[key];
  225.                     if(cmd == command){
  226.                         console.info('AdminCommand \''+cmd+'\' with arguments \''+args+'\' was issued by '+msg.name+'.');
  227.                         if($.inArray( msg.name, ilr.admins ) != -1){
  228.                             try{
  229.                                 if(msg.name == ilr.name){
  230.                                     setTimeout(function(){eval(action);}, 1000);break;
  231.                                 }else{
  232.                                     eval(action);break;
  233.                                 }
  234.                             }catch(e){
  235.                                 sayMessage(msg.name, '\''+command+'\' '+e);
  236.                                 console.error('Bot is unable to process command '+command+'\n\n.Error Message: '+e+'\n\nAction:\n\n'+action);break;
  237.                             }
  238.                         }else{
  239.                             sayMessage(msg.name, 'You don\'t have the required permissions to use "'+command+'".');break;
  240.                         }
  241.                     }
  242.                 }
  243.             };
  244.             lastMessage = msg;
  245.         };
  246.         $('.login').find('input[type="text"]').val(ilr.name);
  247.         $('.usr_submit').click();
  248.         var _t = false;
  249.         $('.message').each( function(i,e){
  250.             if(e.text() == ilr.welcome)
  251.                 var _t = true;return;
  252.         });
  253.         if(!_t){ilr3.shoutbox.send(ilr.welcome);}
  254.         ilr.users.push(ilr.name);
  255.         for (var key in ilr.commands) {
  256.             if (!ilr.commands.hasOwnProperty(key)) continue;
  257.             console.info('Loaded command: '+key+' with action: '+ilr.commands[key]);
  258.         }
  259.         for (var key in ilr.admincommands) {
  260.             if (!ilr.admincommands.hasOwnProperty(key)) continue;
  261.             console.info('Loaded command: '+key+' with action: '+ilr.admincommands[key]);
  262.         }
  263.         //$('*').not('html,body,head,head *,.channel-headline.big,.single-outer.channelbgcolor,script,.flex-outer-allsize.fixed-outer-single-height,.flex-outer-allsize.fixed-outer-single-height *').remove();
  264.         $('#bg,#menue,#channelpreview,#player,p[class="channel-headline"],.channelcover,#channeltoolbox,.social,div[href*="voting"],div[href*="voicemail"],.white'+
  265.          '.single-outer.pointer,div[href="the-battle/"],div[href="rooz-radio-ueberdimensionales-radio-mit-rooz-lee/"],.contactbox,#footer').remove();
  266.         $('.playlist').parent().remove();
  267.         $('.big:contains(Playlist)').remove();
  268.         $('.single-outer').hide();
  269.         $('.flex-outer-allsize.fixed-outer-single-height').css('height', '500px');
  270.         $('#ilr_shoutbox .chat .hidden-scrollbar,#ilr_shoutbox .textarea').css('height', '100%');
  271.         $('.channelbgcolor').css('background-color', 'black').find('*').css('color', 'white');
  272.         console.clear();
  273.     },3000);
  274. })();
Add Comment
Please, Sign In to add comment