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 0000000..cca7ba8 Binary files /dev/null and b/img/download.png differ 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