-
Notifications
You must be signed in to change notification settings - Fork 10
/
newtab.js
55 lines (49 loc) · 1.65 KB
/
newtab.js
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
* Generate HTML List From JavaScript Array
*
* @uri https://getbutterfly.com/generate-html-list-from-javascript-array/
*/
function makeList(listData) {
// Establish the array which acts as a data source for the list
console.log(listData);
// Make a container element for the list
listContainer = document.getElementById("1");
wordContainer = document.getElementById("2");
counter = document.getElementById("3");
// Make the list
listElement = document.createElement("ul");
document.getElementsByTagName("body")[0].appendChild(wordContainer);
numberOfListItems = listData.length;
counter.innerHTML = numberOfListItems;
var rand = listData[Math.floor(Math.random() * numberOfListItems)];
wordContainer.innerHTML = rand;
document.getElementsByTagName("body")[0].appendChild(listContainer);
listContainer.appendChild(listElement);
for (i = 0; i < numberOfListItems; ++i) {
// create an item for each one
listItem = document.createElement("li");
// Add the item text
listItem.innerHTML = listData[i];
// Add listItem to the listElement
listElement.appendChild(listItem);
}
}
async function setList(result) {
if (list != null) {
list = JSON.parse(result.list);
} else {
list = [];
}
makeList(list);
}
function onError(error) {}
let list = browser.storage.sync.get("list");
list.then(setList, onError);
let a = document.getElementById("my-manifest-placeholder");
console.log(a);
const stringManifest = JSON.stringify(myDynamicManifest);
const blob = new Blob([stringManifest], { type: "application/json" });
const manifestURL = URL.createObjectURL(blob);
document
.querySelector("#my-manifest-placeholder")
.setAttribute("href", manifestURL);