CouchPotato Script Injector

Injects the CouchPotato automation script on IMDB movie pages

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         CouchPotato Script Injector
// @namespace    http://www.tampermonkey.net
// @version      0.1
// @description  Injects the CouchPotato automation script on IMDB movie pages
// @author       GCandez
// @match        http://www.imdb.com/title/*
// @grant        none
// ==/UserScript==

//CONFIGURATION


var apiAdress = ''; //The adress for the CouchPotato API (e.g. http://localhost:8080/api)
var apiKey = ''; //The key for the CouchPotato API


(function(){
    //CHECK IF CURRENT PAGE IS MOVIE PAGE
    var element = document.querySelector('meta[property="og:type"]');
    var content = element && element.getAttribute("content");
    var isMovie = content == "video.movie";
    
    if(!isMovie){
        return;
    }
    
    //IS MOVIE, INJECT SCRIPT
    var apiAdressAndKey = apiAdress + '/' + apiKey;
    
    var script = document.createElement('script');
        script.type = 'text/javascript';
        script.src = apiAdressAndKey + '/userscript.bookmark/?host=' + apiAdressAndKey + '/userscript.get/5ssselO1/&r=' + Math.random() * 99999999;

    document.body.appendChild(script);
})();