diff --git a/browser-extension/addTableSortClass.js b/browser-extension/addTableSortClass.js index a42778c..39f0396 100644 --- a/browser-extension/addTableSortClass.js +++ b/browser-extension/addTableSortClass.js @@ -1,10 +1,14 @@ document.body.style.border = "1px solid red"; -let tables = document.querySelectorAll("table"); +function getTables() { + return document.querySelectorAll("table"); +} +let tables = getTables(); console.log("tables", tables); -let tables2 = Array.from(tables).map((table) => { - return table.classList.add("table-sort"); -}); - - - +function addTableSortClass() { + let tablesWithTableSortClass = Array.from(tables).map((table) => { + return table.classList.add("table-sort"); + }); + return tablesWithTableSortClass; +} +addTableSortClass(); diff --git a/browser-extension/getTableHeaders.js b/browser-extension/getTableHeaders.js index eaafe05..1c9f15c 100644 --- a/browser-extension/getTableHeaders.js +++ b/browser-extension/getTableHeaders.js @@ -1,7 +1,7 @@ -// let tables = document.querySelectorAll("table").querySelectorAll("th"); -// console.log("tables3", tables); -let headers = document.querySelectorAll("table th"); -console.log("tables3", headers); - -let headerText = headers.map((header)=>header.innerHTML) -console.log(headerText) +function getTableHeaders() { + let headers = document.querySelectorAll("table th"); + let headerNames = Array.from(headers).map((header) => header.innerText); + console.log("test", headerNames); + return headerNames; +} +getTableHeaders(); diff --git a/browser-extension/manifest.json b/browser-extension/manifest.json index 870ae3e..57c7d09 100644 --- a/browser-extension/manifest.json +++ b/browser-extension/manifest.json @@ -1,13 +1,17 @@ { "manifest_version": 2, + "author":"Lee Wannacott", "name": "table-sort-js", "version": "0.0", "description": "Makes tables sortable using https://github.com/LeeWannacott/table-sort-js", - "icons": { "48": "icons/t.png" } , - + "browser_action": { + "default_icon": "./icons/t.png", + "default_title": "table-sort", + "default_popup": "popup/table-options.html" + }, "content_scripts": [ { "matches": [ @@ -17,12 +21,5 @@ ], "js": ["addTableSortClass.js","getTableHeaders.js","table-sort.js"] } - ], - - "browser_action": { - "default_icon": "./icons/t.png", - "default_title": "table-sort", - "default_popup": "popup/table-options.html" - } - + ] } diff --git a/browser-extension/popup/table-options.html b/browser-extension/popup/table-options.html index d273557..73ea23f 100644 --- a/browser-extension/popup/table-options.html +++ b/browser-extension/popup/table-options.html @@ -1,15 +1,17 @@ -
- - -