Skip to content

Instantly share code, notes, and snippets.

@SavageCore
Last active November 26, 2016 06:38
Show Gist options
  • Save SavageCore/2432769391b727b022f7c509b1429757 to your computer and use it in GitHub Desktop.
Save SavageCore/2432769391b727b022f7c509b1429757 to your computer and use it in GitHub Desktop.
It only checks for torrents of the same imdb, not the specific request. Preview: http://i.imgur.com/HCmqiH3.png
// ==UserScript==
// @name Check KG for PTP Requests
// @namespace https://savagecore.eu
// @description Add link to PTP requests page if found at KG
//
// @version 0.1.0
// @include http*://*passthepopcorn.me/requests.php*
//
// @connect karagarga.in
// @downloadURL https://gist.github.com/SavageCore/2432769391b727b022f7c509b1429757/raw/f757e33f464d22d31e565b5c9514ab4fc468bb92/script.user.js
// @grant GM_xmlhttpRequest
//
// ==/UserScript==
if (window.top != window.self) // Don't run on frames or iframes
{
return;
}
var imdbIDs = Array();
[].forEach.call(document.querySelectorAll('#request_table > tbody > tr'), function (tr) {
var element = tr.querySelectorAll('td > .imdbtitle > a')[0];
if (element) {
var regex = /http:\/\/(?:www\.)?imdb\.com\/title\/(tt[^/]+)(?:\/)?/gm;
match = regex.exec(String(element.href));
if (match) {
imdbID = match[1];
imdbIDs.push(imdbID);
}
}
});
// Foreach request page do search
for (var i = 0; i < imdbIDs.length; i++) {
// Search KG
GM_xmlhttpRequest({
method: 'GET',
url: 'https://karagarga.in/browse.php??search_type=imdb&search=' + imdbIDs[i],
onload: function (response) {
var regex = /<h2>No torrents found/;
match = regex.exec(response.responseText);
if (!match) {
// Torrents found append link
var regex2 = /http:\/\/(?:www\.)?imdb\.com\/title\/(tt\d+)/;
var match2 = regex2.exec(response.responseText);
if (match2) {
imdbID = match2[1];
element = document.querySelectorAll('a[href*="' + imdbID + '"]');
tags = element[0].parentNode.parentNode.querySelectorAll('.tags')[0];
tags.innerHTML = tags.innerHTML + ' | <a href="https://karagarga.in/browse.php?search=' + imdbID + '&search_type=imdb" target="_blank" style="color: #43A047">KG</a>';
}
}
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment