Skip to content

Instantly share code, notes, and snippets.

@velnias75
Last active October 21, 2018 09:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save velnias75/2eb5a3625640ada0007d3d2c0de09eb5 to your computer and use it in GitHub Desktop.
Save velnias75/2eb5a3625640ada0007d3d2c0de09eb5 to your computer and use it in GitHub Desktop.
Userscript um Filme von omdb in der Datenbank https://rangun.de/index.php zu suchen
// ==UserScript==
// @name OMDB - Suche in der DB
// @version 0.15
// @description Userscript um Filme von omdb in der Datenbank https://rangun.de/index.php zu suchen
// @author Heiko Schäfer
// @homepage https://gist.github.com/velnias75/2eb5a3625640ada0007d3d2c0de09eb5
// @updateURL https://gist.github.com/velnias75/2eb5a3625640ada0007d3d2c0de09eb5/raw/omdb.user.js
// @downloadURL https://gist.github.com/velnias75/2eb5a3625640ada0007d3d2c0de09eb5/raw/omdb.user.js
// @namespace https://rangun.de/db/
// @match http://www.omdb.org/person/*/filmography
// @match http://www.omdb.org/movie/*
// @match http://www.omdb.org/user/*
// @match https://www.omdb.org/person/*/filmography
// @match https://www.omdb.org/movie/*
// @match https://www.omdb.org/user/*
// @require https://cdn.jsdelivr.net/g/jquery
// @run-at document-end
// @connect *
// @grant GM_xmlhttpRequest
// @grant GM_getValue
// @grant GM_setValue
// ==/UserScript==
function escapeRegExp(string) {
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
}
var pathname = window.location.pathname;
if(pathname.match(/\/person\/[^\/]+\/filmography/)) {
$("table#filmography tbody > tr").each(function(i) {
var temel = $(this).find("td a");
var title = temel.text().replace(/ - /g, " – ");
if(title.length) {
GM_xmlhttpRequest({
method: "GET",
url: GM_getValue('webvirus_url', 'https://rangun.de/db') + "/title-json.php?filter_ltitle=" +
encodeURIComponent("/^" + escapeRegExp(title) + "$/"),
anonymous: true,
timeout: 0,
onload: function(response) {
if(response.status == 200) {
var json = eval(response.responseText);
if(typeof json[0] != 'undefined' && json.length == 1) {
$(document).ready(function () {
temel.text('⚠ ' + title + ' ⚠');
});
}
}
}
});
}
});
}
if(pathname.substring(1, 5) == 'movi') {
var title = $("#headline > h2:nth-child(2)").text().replace(/ - /g, " – ");
var o_title = $("#headline > h3:nth-child(3)").text().replace(/ - /g, " – ");
var aliases = o_title.length > 0 ? ("(" + escapeRegExp(o_title.trim()).replace(/ - /g, " – ") + ")|") : "";
$("#overview-aliases.content-box ul li").each(function(i) {
aliases += "(" + escapeRegExp($(this).text().trim()).replace(/ - /g, " – ") + ")|";
});
GM_xmlhttpRequest({
method: "GET",
url: GM_getValue('webvirus_url', 'https://rangun.de/db') + "/title-json.php?id=1&filter_ltitle=" +
encodeURIComponent("/^" + aliases + "(" + escapeRegExp(title) + ")$/"),
anonymous: true,
timeout: 0,
onload: function(response) {
if(response.status == 200) {
var json = eval(response.responseText);
if(typeof json[0] != 'undefined' && json.length == 1) {
$("div#external-links.wikilist ul").
append('<li><a target="webvirus" href="' + GM_getValue('webvirus_url', 'https://rangun.de/db') + '/index.php?filter_ltitle=' +
"%23" + json[0].id + '">Zeige in der DB</a></li>');
$(document).ready(function () {
var th = $("#headline > h2:nth-child(2)"); console.log(encodeURIComponent(document.location.toString()));
th.html('✋&nbsp;#' + json[0].id + " - " + $("#headline > h2:nth-child(2)").text() + '&nbsp;✋');
if(GM_getValue('webvirus_ombd_id_update', false)) {
th.append('<a title="&Uuml;bernehme omdb-ID in DB" href="' + GM_getValue('webvirus_url', 'https://rangun.de/db') + '/omdb.php?mid=' +
json[0].id + '&oid=' + /^\/movie\/([0-9]+)\-.*$/.exec(document.location.pathname)[1] +
'&url=' + encodeURIComponent(document.location.toString()) + '">&#9745;</a>');
}
});
}
}
}
});
}
if(pathname.substring(1, 5) == 'user') {
$('div#overview-details').append('<div class="headline-box"><h3>DB-Link einstellen</h3></div><div class="content-box"><input id="webvirus-url" type="text" value="' +
GM_getValue('webvirus_url', 'https://rangun.de/db') + '" /></div>');
$('#webvirus-url').on('input', function() {
GM_setValue('webvirus_url', $(this).val());
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment