// ==UserScript== // @name Torrent Quick Search // @namespace https://github.com/TMD20/torrent-quick-search // @supportURL https://github.com/TMD20/torrent-quick-search // @version 1.1.5 // @description Toggle for Searching Torrents via Search aggegrator // @icon https://cdn2.iconfinder.com/data/icons/flat-icons-19/512/Eye.png // @author tmd // @noframes // @inject-into page // @run-at document-end // @require https://openuserjs.org/src/libs/sizzle/GM_config.min.js // @grant GM_getValue // @grant GM_setValue // @grant GM.xmlhttpRequest // @grant GM.registerMenuCommand // @grant GM.notification // @match https://animebytes.tv/requests.php?action=viewrequest&id=* // @match https://animebytes.tv/series.php?id=* // @match https://animebytes.tv/torrents.php?id=* // @match https://blutopia.xyz/requests/* // @match https://blutopia.xyz/torrents/* // @match https://beyond-hd.me/requests/* // @match https://beyond-hd.me/torrents/* // @match https://imdb.com/title/* // @match https://www.imdb.com/title/* // @match https://www.themoviedb.org/movie/* // @match https://www.themoviedb.org/tv/* // @license MIT // @downloadURL none // ==/UserScript== ` General Functions Functions that don't fit in any other catergory ` async function toggleSearch(e){ content=document.querySelector("#searchcontent") if (content.style.visibility === "visible") { content.style.pointerEvents="none" document.querySelector("#toggle").style.height='2%' document.querySelector("#toggle").style.width='2%' content.style.visibility = "hidden"; } else { content.style.pointerEvents="all" document.querySelector("#toggle").style.height='5%' document.querySelector("#toggle").style.width='5%' content.style.visibility = "visible"; try{ await doSearch() } catch(error) { GM.notification(error.toString(), program,searchIcon) document.querySelector("#toggle").style.height='2%' document.querySelector("#toggle").style.width='2%' document.querySelector("#searchcontent").style.visibility = "hidden"; throw new Error(error); } } } async function doSearch(){ document.querySelector("#msgnode").textContent="Loading" reqs=[] resetResultList() url=await getBaseURL() indexers=await getIndexers() getTableHead() document.querySelector("#msgnode").textContent="Fetching Results" imdb=await getIMDB() data = await Promise.allSettled(indexers.map((e)=>searchIndexer(e,imdb))); addNumbers() console.log("Finished Fetching") document.querySelector("#msgnode").textContent="Finished" } async function searchIndexer(indexerObj,imdb){ console.log(`Fetching From ${indexerObj["name"]}`) req=await fetch(`${url}&indexerIds=${indexerObj["id"]}`) data=JSON.parse(req.responseText) filterData=data.filter((e)=>imdbFilter(e,imdb)) processResults(JSON.parse(req.responseText)) } function fetch(url){ return new Promise((resolve, reject) => { GM.xmlhttpRequest( { 'method' : 'GET', 'url' : url, 'responseType':"json", onload : response => { resolve(response) }, onerror : response => { reject(response.responseText) }, } ) })} function getParser(){ siteName=standardNames[window.location.host] || window.location.host data=infoParser[siteName] if (data===undefined){ msg="Could not get Parser" GM.notification(msg, program,searchIcon) throw new Error(msg); } return data } function verifyConfig(){ if (GM_config.get('searchapi',"null")=="null"||GM_config.get('searchurl',"null")=="null"){ return false } if (GM_config.get('searchapi',"null")==""||GM_config.get('searchurl',"null")==""){ return false } return true } ` DOM Manipulators These Functions are used to manipulate the DOM ` function getTableHead(){ resultList=document.querySelector("#resultlist") node=document.createElement("div"); node.setAttribute("id","resulthead") node.innerHTML=`