-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
49 lines (41 loc) · 1.16 KB
/
script.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
let myLeads = []
const inputBtn = document.getElementById("input-btn")
const deleteBtn = document.getElementById("delete-btn")
const txtInput = document.getElementById("input")
const ul_EL = document.getElementById("ulEl")
const leadsLocalStorage = JSON.parse(localStorage.getItem("myLeads"))
const tabBtn = document.getElementById("tab-btn")
if(leadsLocalStorage){
myLeads = leadsLocalStorage
render(myLeads)
}
function render(leads){
let listItmems = ""
for (let i = 0; i < leads.length; i++){
listItmems += `
<li>
<a a target='_blank 'href='${leads[i]}'>
${leads[i]}
</a>
</li>`
}
ul_EL.innerHTML = listItmems
}
deleteBtn.addEventListener("dblclick", function(){
localStorage.clear()
myLeads = []
render(myLeads)
})
inputBtn.addEventListener("click", function(){
myLeads.push(txtInput.value)
txtInput.value = ""
localStorage.setItem("myLeads", JSON.stringify(myLeads))
render(myLeads)
})
tabBtn.addEventListener('click', function(){
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
myLeads.push(tabs[0].url)
localStorage.setItem("myLeads", JSON.stringify(myLeads))
render(myLeads)
})
})