// ==UserScript==
// @name RARBG Helper
// @name:zh-CN RARBG 助手
// @namespace https://peratx.net
// @version 1.1.0
// @description Powerful Toolbox for RARBG.
// @description:zh-cn 为 [RARBG](https://rarbgprx.org) 定制的强力工具箱。
// @author PeratX
// @license Apache License 2.0
// @match *://rarbg.to/*
// @match *://rargb.to/*
// @match *://rarbgmirror.org/*
// @match *://rarbgmirror.com/*
// @match *://rarbgproxy.org/*
// @match *://rarbgunblock.com/*
// @match *://rarbg.is/*
// @match *://rarbgmirror.xyz/*
// @match *://rarbg.unblocked.lol/*
// @match *://rarbg.unblockall.org/*
// @match *://rarbgaccess.org/*
// @match *://rarbg2018.org/*
// @match *://rarbgtorrents.org/*
// @match *://rarbgproxied.org/*
// @match *://rarbgget.org/*
// @match *://rarbgprx.org/*
// @connect *
// @supportURL https://github.com/PeratX/RARBGHelper
// @grant GM_xmlhttpRequest
// @downloadURL none
// ==/UserScript==
(function () {
'use strict';
const githubStar = '';
function getStringBetween(str, begin, end) {
if (str.indexOf(begin) >= 0) {
let index = str.indexOf(begin);
return str.substring(index + begin.length + 1, str.indexOf(end, index));
}
return false;
}
if (window.location.href.indexOf("torrents.php") >= 0) {
let cache = [];
function addRating(a) {
let page = a.getAttribute("href")
if (!cache[page]) {
cache[page] = true;
fetch(page).then(body => body.text()).then(b => {
let parser = new DOMParser().parseFromString(b, "text/html");
let dl = parser.querySelector("td.lista a[id]");
a.parentNode.innerHTML += "Rating: " + parser.querySelector("li.current-rating").innerHTML.replace("Currently ", "").trim() + " " +
'Download Torrent Magnet';
})
}
}
document.onmousemove = function (k) {
let xoff = k.pageX + xoffset;
let yoff = k.pageY + yoffset;
el = k.target || k.srcElement
if (pop.children[0]) {
let top = document.scrollingElement.scrollTop + document.scrollingElement.clientHeight - pop.children[0].height - 10
if (yoff > top) {
yoff = top
}
}
pop.style.top = yoff + "px";
pop.style.left = xoff + "px"
};
let a = document.querySelectorAll('tr[class="lista2"] > td:nth-child(2) >a:nth-child(1)')
for (let i = 0; i < a.length; i++) {
a[i].parentNode.innerHTML += ' '
}
a = document.querySelectorAll('tr[class="lista2"] > td:nth-child(2) >a:nth-child(1)')
for (let i = 0; i < a.length; i++) {
let ev = a[i].attributes.onmouseover
if (ev === false) {
continue
}
a[i].addEventListener('mouseover', function (e) {
addRating(a[i])
})
// process image
let parts = ev.value.split('/')
switch (parts[3]) {
case 'static':
switch (parts[4]) {
case 'over': //18+
ev.value = ev.value.replace('static/over', 'posters2/' + parts[5].substr(0, 1))
break;
case '20': //TVdb
ev.value = ev.value.replace('_small', '_banner_optimized')
break;
}
break;
case 'mimages': //movie
ev.value = ev.value.replace('over_opt', 'poster_opt')
break;
}
}
document.getElementById("divadvsearch").innerHTML += "RARBG Helper" + githubStar
} else {
function setImage(a, img) {
a.setAttribute("href", img);
a.getElementsByTagName("img")[0].setAttribute("src", img);
}
let desc = document.getElementById("description");
desc.innerHTML = 'RARBG Helper EnabledMade by PeratX@iTXTech.org ' + githubStar + '
' + desc.innerHTML;
let a = desc.getElementsByTagName("a");
for (let i in a) {
if (typeof a[i] == "object") {
GM_xmlhttpRequest({
method: "GET",
url: a[i].getAttribute("href"),
onload: function (response) {
// 22pixx, imgprime
let img = getStringBetween(response.responseText, "linkid=", '";');
if (img !== false) {
GM_xmlhttpRequest({
method: "GET",
url: img,
onload: function (response) {
let img = getStringBetween(response.responseText, "