diff --git a/manifest.json b/manifest.json index e18e706..20dddc9 100644 --- a/manifest.json +++ b/manifest.json @@ -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 } \ No newline at end of file diff --git a/yggplus.js b/yggplus.js index 6273419..9d0f78f 100644 --- a/yggplus.js +++ b/yggplus.js @@ -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 = 'Télécharger'; - row.appendChild(td); - }; -}); \ No newline at end of file + const link = row.cells[1].firstChild.href; + const name = link.substr(link.lastIndexOf("/") + 1); + const id = name.substr(0, name.indexOf("-")); + + td.innerHTML = + 'Télécharger'; + row.appendChild(td); + } + }); + } +} + +checkData();