forked from HamidByte/Wiki-Table-Exporter-Chrome-Extension
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpopup.js
More file actions
25 lines (22 loc) · 1.11 KB
/
popup.js
File metadata and controls
25 lines (22 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
document.addEventListener("DOMContentLoaded", function () {
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
chrome.tabs.sendMessage(tabs[0].id, { action: "getTables" }, function (response) {
const tablesList = document.getElementById("tables-list")
response.tables.forEach(function (table, index) {
const button = document.createElement("button")
button.textContent = "Download Table " + (index + 1)
button.addEventListener("click", function () {
chrome.tabs.sendMessage(tabs[0].id, { action: "downloadTable", tableIndex: index, includeUrls: false })
})
const buttonWithUrls = document.createElement("button")
buttonWithUrls.className = "with-urls"
buttonWithUrls.textContent = "Download Table " + (index + 1) + " (with URLs)"
buttonWithUrls.addEventListener("click", function () {
chrome.tabs.sendMessage(tabs[0].id, { action: "downloadTable", tableIndex: index, includeUrls: true })
})
tablesList.appendChild(button)
tablesList.appendChild(buttonWithUrls)
})
})
})
})