Add Link To IMDb Code

Add Link To IMDb Code Like "tt1234567"; Better With Add IMDb Rating Script

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         Add Link To IMDb Code
// @namespace    http://tampermonkey.net/
// @version      0.1.0
// @description  Add Link To IMDb Code Like "tt1234567"; Better With Add IMDb Rating Script
// @author       Mumumi
// @include      *
// @exclude      *greasyfork.org*
// @grant        none
// @run-at       document-end
// ==/UserScript==

function GetByXPath(xpath){
    try {
        return document.evaluate(xpath, document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
    } catch (e) {
        console.log('ASget'+e);
    }
    return false;
}

//window.onload = function() {
    var imdbslist = ["IMDb", "IMDB", "imdb", "Imdb", "iMdb", "imDb", "imdB", "IMdb", "ImDb", "ImdB", "iMDb", "iMdB", "imDB", "IMdB", "ImDB", "iMDB"];
    for (var i in imdbslist) {
        try {
            var elem = GetByXPath('(//*[contains(.,"'+imdbslist[i]+'") and ./*[not(contains(.,"'+imdbslist[i]+'"))]])[last()]').snapshotItem(0);
            var html = elem.innerHTML;
            elem.innerHTML = html.replace(/([^/])(tt\d{7})/i,"$1<a href=\"http://www.imdb.com/title/$2/\">$2</a>");
        } catch (e) {
            console.log('ASget'+e);
        }
    }
//};