Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Automeh
- // @version 0.2
- // @description /meh add "string" or /regex/ ; /meh del "string" or /regex/ ; /meh list ; /meh share ; /meh clear ; /meh this
- // @author Ravana
- // @match https://plug.dj/*
- // @require http://code.jquery.com/jquery-latest.js
- // ==/UserScript==
- setTimeout(function() {
- var mehTriggers = [];
- if(localStorage["mehTriggers"]){
- mehTriggers = JSON.parse(localStorage["mehTriggers"]);
- }
- API.on(API.CHAT_COMMAND, function(arg){
- var data = arg.split(" ");
- if(data[0]!="/meh")return;
- if(data[1]=="add"){
- data.shift();
- data.shift();
- data = data.join(" ");
- if(data[0]=='"' && data.slice(-1)=='"'){
- } else {
- if(data[0]=='/' && data.slice(-1)=='/'){
- } else {
- API.chatLog('Invalid input. Usage: /meh add "string" or /regex/');
- return;
- }
- }
- mehTriggers.push(data);
- localStorage["mehTriggers"] = JSON.stringify(mehTriggers);
- API.chatLog("Automeh trigger added: "+data);
- }
- if(data[1]=="del"){
- data.shift();
- data.shift();
- data = data.join(" ");
- var index = mehTriggers.indexOf(data);
- if (index >= 0) {
- mehTriggers.splice( index, 1 );
- localStorage["mehTriggers"] = JSON.stringify(mehTriggers);
- API.chatLog("Automeh trigger removed: "+data);
- }
- }
- if(data[1]=="list"){
- API.chatLog(mehTriggers.join(" | "));
- // need something else for long list
- }
- if(data[1]=="this"){
- data = '"'+API.getMedia().author.toLowerCase() + " - " + API.getMedia().title.toLowerCase()+'"';
- mehTriggers.push(data);
- localStorage["mehTriggers"] = JSON.stringify(mehTriggers);
- API.chatLog("Automeh trigger added: "+data);
- }
- if(data[1]=="share"){
- API.sendChat("My Automeh matches: "+mehTriggers.join(" | "));
- // need something else for long list
- }
- if(data[1]=="clear"){
- API.chatLog("Automeh matches cleared: "+mehTriggers.join(" | "));
- mehTriggers=[];
- localStorage["mehTriggers"] = "";
- }
- })
- API.on(API.ADVANCE,function(data){
- var title = data.media.author.toLowerCase() + " - " + data.media.title.toLowerCase();
- mehTriggers.forEach(function(entry) {
- if(entry[0]=='"'){
- // STRING MATCH
- entry = entry.slice(1, -1);
- if(title.indexOf(entry)>-1){
- API.chatLog("Automeh string match found with "+entry);
- $("#meh").click();
- setTimeout(function(){$("#meh").click()},10000);
- return;
- }
- }
- if(entry[0]=='/'){
- // REGEX MATCH
- entry = entry.slice(1, -1);
- var reg = new RegExp(entry);
- if(title.match(reg)){
- API.chatLog("Automeh regex match found with "+entry);
- $("#meh").click();
- setTimeout(function(){$("#meh").click()},10000);
- return;
- }
- }
- });
- })
- },10000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement