// ==UserScript== // @name Torrenter // @namespace http://www.google.com/search?q=mabakay // @description Adds links pointing to torrent sites. // @include http://release24.pl/* // @include http://www.filmweb.pl/* // @grant none // @copyright 2010 - 2014, mabakay // @date 14 December 2014 // @version 1.46 // @license GPL version 3 or any later version; http://www.gnu.org/copyleft/gpl.html // @downloadURL none // ==/UserScript== var Engines = ["http://kickass.to/usearch/{0}/?field=seeders&sorder=desc", "https://www.torrentz.com/search?q={0}", "http://extratorrent.cc/search/?search={0}", "http://bitsnoop.com/search/all/{0}/s/a/1/", "http://www.1337x.to/search/{0}/1/", "http://www.sumotorrent.sx/en/search/{0}?order=seeders&by=down"]; var hostName = window.location.hostname; if (hostName == 'release24.pl') { var titleElement = document.getElementById('mainwindow'); loopCount = titleElement.childElementCount > 3 ? titleElement.childElementCount - 3 : 2; for (i = 1; i < loopCount; i++) { var elem = titleElement.children[i]; if (elem.className == 'wpis') { var title_regex = /\"(.*)\"/; regex_result = elem.children[0].children[0].innerHTML.match(title_regex) if (regex_result != null) { var title = regex_result[1]; var span = createLinkSpan(title, 'margin-left: 50px; font-weight: normal;'); elem.children[2].children[0].children[0].children[0].children[0].children[1].children[0].children[0].children[0].appendChild(span); } } } } else if (hostName == 'www.filmweb.pl') { var style = 'margin-left: 15px; font-weight: normal; font-size: 0.5em;'; var titleElement = $('.filmMainHeader .hdr:first'); var title; if (titleElement.length == 1) { var smallTitleElement = titleElement.siblings('.cap:first'); if (smallTitleElement.length == 1) { title = smallTitleElement.text(); } else { title = titleElement.find('a').text(); } } if (titleElement.length && title) { var span = createLinkSpan(title, style); titleElement.append(span); } } function createLinkSpan(title, style) { var span = document.createElement('span'); span.setAttribute('id', 'Torrenter'); span.setAttribute('style', style); for (var i = 0; i < Engines.length; i++) { var link = document.createElement('a'); link.setAttribute('href', format(Engines[i], encodeURIComponent(title))); link.setAttribute('style', 'position: relative; top: 5px;'); var urlRegex = /(https?:\/\/)(.+\....)/; var regexResult = Engines[i].match(urlRegex); link.innerHTML = getFavIconImg(regexResult[2]); if (i > 0) { var separator = document.createElement('span'); separator.innerHTML = ' | '; span.appendChild(separator); } span.appendChild(link); } return span; } function getFavIconImg(url) { var imgurl = ''; return imgurl; } function format(str) { for (var i = 1; i < arguments.length; i++) { var argNum = "{" + (i - 1) + "}"; str = str.replace(argNum, arguments[i]); } return str; }