From 58c845b84f1188a0d64db6d158b760c4db3a764f Mon Sep 17 00:00:00 2001 From: vermillion-dev Date: Mon, 6 May 2019 20:32:47 +0200 Subject: [PATCH] Add dl button and auto date sorting to search --- contentScripts/search/search.js | 27 +++++++++++++++++++++++++++ img/download.png | Bin 0 -> 636 bytes manifest.json | 9 ++++++++- 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 contentScripts/search/search.js create mode 100644 img/download.png diff --git a/contentScripts/search/search.js b/contentScripts/search/search.js new file mode 100644 index 0000000..764954a --- /dev/null +++ b/contentScripts/search/search.js @@ -0,0 +1,27 @@ +var path = window.location.toString(); +var args = path.split('&'); +if (args[args.length -1] === 'do=search') { + window.location.replace(path + '&order=desc&sort=publish_date'); +} +else { + var table = document.getElementsByTagName('tbody')[1]; + + function addDlButton(idx, torrentId, yggToken) { + var cell = table.rows[idx].cells[2]; + var downloadButton = document.createElement('a') + var downloadIcon = document.createElement('img') + downloadIcon.setAttribute('src', chrome.extension.getURL("img/download.png")); + downloadButton.appendChild(downloadIcon); + downloadButton.setAttribute('href', "https://www2.yggtorrent.ch/rss/download?id=" + torrentId + "&passkey=" + yggToken); + cell.appendChild(downloadButton); + } + + chrome.storage.sync.get(['yggToken'], function(value){ + if(value.yggToken){ + for (var i = 0; i < table.rows.length; i++) { + var torrentId = table.rows[i].cells[2].children[0].getAttribute('target') + addDlButton(i, torrentId, value.yggToken); + } + } + }); +} \ No newline at end of file diff --git a/img/download.png b/img/download.png new file mode 100644 index 0000000000000000000000000000000000000000..cca7ba8d944565b3a8a761ed939d92e2bea43b60 GIT binary patch literal 636 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GXl47~=zcLR^8|irNl1a&d9MiWqfM z7<5yS5sOwTyM7{&lr;|pYS(fu0FwXz|NrynPkBxIUk|MKm}*Y7_|t6JW?`}pb0_s?H{{Qmv>)!Ps6KYji1`CI3lEqZ}9Qnp!d zKYV%j@#~{!uh>n;x*5ickK73%YS*y^IpCE{PNAG zhfiK@KX^X2d?tr!UeTIw-MfEqndiND^YQuX4-X!{xcBH;OxXTtanUg`{Qtn2Ub8u zn>}3|LnI_^4;tz_2TC+N{BC=FYKM!*tQY1HI%bQn`t^v__eb#d9?95z<4FDlp{rR2 zbE;*Ro6K`>*XiBAk|#1?_j5Ue7{>bAJtbS(UPt(*etx_1YQgDsXMax4TGYm@yHt`n zHO)*WDsV5K-0piG)|H{FjP6#PxOpRVrPrn3mTtEuuTuH?PWEuE*8e-_c=#En=b6~B z{EwBCTR82>p`~qWWc&Tr?f1J{{5(%x>P4fmzMAiU=CyZC%YNy;_60hh!PC{xWt~$( F695e?Qbzy) literal 0 HcmV?d00001 diff --git a/manifest.json b/manifest.json index faf97fd..c613d54 100644 --- a/manifest.json +++ b/manifest.json @@ -22,7 +22,8 @@ "web_accessible_resources" : [ "contentScripts/addTorrent/accessAddTorrent.js", "contentScripts/allPages/accessAllPages.js", - "css/style.css" + "css/style.css", + "img/download.png" ], "content_scripts": [ { @@ -39,6 +40,12 @@ "matches": ["https://*.yggtorrent.ch/*"], "run_at": "document_idle", "js": ["js/utilsFunctions.js", "contentScripts/allPages/allPages.js"] + }, + { + "matches": ["https://www2.yggtorrent.ch/engine/search*"], + "run_at": "document_idle", + "js": ["js/utilsFunctions.js", "contentScripts/search/search.js"] + } ], "manifest_version": 2