Skip to content

Commit

Permalink
handle li domain and ajax tables
Browse files Browse the repository at this point in the history
  • Loading branch information
arnauddrain committed May 16, 2021
1 parent 1530e3f commit 70a711f
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 23 deletions.
22 changes: 15 additions & 7 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
{
"name": "YGG Plus",
"version": "1.0",
"version": "1.1",
"description": "Add buttons to ygg torrent",
"icons": {
"128": "128.png"
},
"content_scripts": [ {
"all_frames": true,
"js": [ "yggplus.js" ],
"matches": [ "https://www2.yggtorrent.gg/*", "https://www.yggtorrent.gg/*", "https://www3.yggtorrent.gg/*" ]
} ],
},
"content_scripts": [
{
"all_frames": true,
"js": [
"yggplus.js"
],
"matches": [
"https://yggtorrent.li/*",
"https://www.yggtorrent.li/*",
"https://www4.yggtorrent.li/*"
]
}
],
"manifest_version": 2
}
45 changes: 29 additions & 16 deletions yggplus.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
const tables = document.querySelectorAll('table.table');
tables.forEach(table => {
let th = document.createElement('th');
th.colSpan = 1;
th.innerText = 'Actions';
table.tHead.rows[0].appendChild(th);
function checkData() {
const tables = document.querySelectorAll("table.table");
if (!tables.length) {
return;
} else if (!tables[0].tBodies[0].rows.length) {
setTimeout(checkData, 100);
} else {
tables.forEach((table) => {
let th = document.createElement("th");
th.colSpan = 1;
th.innerText = "Actions";
table.tHead.rows[0].appendChild(th);

for (let row of table.tBodies[0].rows) {
let td = document.createElement('td');
for (let row of table.tBodies[0].rows) {
let td = document.createElement("td");

const link = row.cells[1].firstChild.href;
const name = link.substr(link.lastIndexOf('/') + 1);
const id = name.substr(0, name.indexOf('-'));

td.innerHTML = '<a href="https://www2.yggtorrent.gg/engine/download_torrent?id=' + id + '">Télécharger</a>';
row.appendChild(td);
};
});
const link = row.cells[1].firstChild.href;
const name = link.substr(link.lastIndexOf("/") + 1);
const id = name.substr(0, name.indexOf("-"));

td.innerHTML =
'<a href="https://www4.yggtorrent.li/engine/download_torrent?id=' +
id +
'">Télécharger</a>';
row.appendChild(td);
}
});
}
}

checkData();

0 comments on commit 70a711f

Please sign in to comment.