mirror of
https://github.com/NohamR/BetterYGG.git
synced 2026-01-10 08:18:19 +00:00
Add dl button and auto date sorting to search
This commit is contained in:
27
contentScripts/search/search.js
Normal file
27
contentScripts/search/search.js
Normal 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
BIN
img/download.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 636 B |
@@ -22,7 +22,8 @@
|
|||||||
"web_accessible_resources" : [
|
"web_accessible_resources" : [
|
||||||
"contentScripts/addTorrent/accessAddTorrent.js",
|
"contentScripts/addTorrent/accessAddTorrent.js",
|
||||||
"contentScripts/allPages/accessAllPages.js",
|
"contentScripts/allPages/accessAllPages.js",
|
||||||
"css/style.css"
|
"css/style.css",
|
||||||
|
"img/download.png"
|
||||||
],
|
],
|
||||||
"content_scripts": [
|
"content_scripts": [
|
||||||
{
|
{
|
||||||
@@ -39,6 +40,12 @@
|
|||||||
"matches": ["https://*.yggtorrent.ch/*"],
|
"matches": ["https://*.yggtorrent.ch/*"],
|
||||||
"run_at": "document_idle",
|
"run_at": "document_idle",
|
||||||
"js": ["js/utilsFunctions.js", "contentScripts/allPages/allPages.js"]
|
"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
|
"manifest_version": 2
|
||||||
|
|||||||
Reference in New Issue
Block a user