-
Notifications
You must be signed in to change notification settings - Fork 1
/
pop.js
91 lines (88 loc) · 2.58 KB
/
pop.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
var launch_all=document.getElementById('launch-all');
launch_all.addEventListener('click',function(){
UpdateLinks();
});
var urls=[]
function UpdateLinks(){
for(var i in urls){
window.open(urls[i]);
}
}
function copyURL(field){
chrome.storage.sync.get(field,(url)=>{
var copyText = url[field];
const el = document.createElement('textarea');
el.value = copyText;
document.body.appendChild(el);
el.select();
document.execCommand('copy');
document.body.removeChild(el);
})
}
document.querySelectorAll('.copy_btn').forEach(item => {
console.log(item.getAttribute("name"))
var name = item.getAttribute("name");
item.addEventListener('click', e => {
copyURL(name);
})
})
var name_field=document.getElementById('name')
var website=document.getElementById('website')
var github=document.getElementById('github')
var linkedin=document.getElementById('linkedin')
var twitter=document.getElementById('twitter')
var instagram=document.getElementById('instagram')
var edit_btn=document.getElementById('edit')
var keys=["name","website","github","linkedin","twitter","instagram"];
chrome.storage.sync.get(keys,function(links){
if(!chrome.runtime.error){
if(links.name){
name_field.innerHTML=links.name;
}
if(links.website){
website.href=links.website;
urls.push(links.website)
}
else{
website.addEventListener('click',function(event){
event.preventDefault();
})
}
if(links.github){
github.href=links.github;
urls.push(links.github)
}
else{
github.addEventListener('click',function(event){
event.preventDefault();
})
}
if(links.linkedin){
linkedin.href=links.linkedin;
urls.push(links.linkedin)
}
else{
linkedin.addEventListener('click',function(event){
event.preventDefault();
})
}
if(links.twitter){
twitter.href=links.twitter;
urls.push(links.twitter)
}
else{
twitter.addEventListener('click',function(event){
event.preventDefault();
})
}
if(links.instagram){
instagram.href=links.instagram;
urls.push(links.instagram)
}
else{
instagram.addEventListener('click',function(event){
event.preventDefault();
})
}
}
})