Add dl button and auto date sorting to search

This commit is contained in:
vermillion-dev
2019-05-06 20:32:47 +02:00
parent f408526172
commit 58c845b84f
3 changed files with 35 additions and 1 deletions

View File

@@ -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);
}
}
});
}

BIN
img/download.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 636 B

View File

@@ -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