Repository navigation
Expand file tree
/
Copy pathpopup.js
More file actions
67 lines (57 loc) · 2.21 KB
/
Copy pathpopup.js
File metadata and controls
67 lines (57 loc) · 2.21 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
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
//
//window.onload = function(){
// click();
//}
//
loadCSS();
//fake css for run my function after loading of css START____________________________
function loadCSS(url, callback){
url = "fakeCss.css";
var link = document.createElement('link');
link.type = 'text/css';
link.rel = 'stylesheet';
link.href = url;
document.getElementsByTagName('head')[0].appendChild(link);
var img = document.createElement('img');
img.onerror = function(){
//if(callback){
// chrome.extension.sendMessage({greeting: "hello"}, function (response) {});
//}
//else{
// callback(link);
//}
(callback) ? alert("stylesheet loaded") : click() ;
}
img.src = url;
}
//fake css ENDS___________________________________________________________
function click(){
chrome.extension.sendMessage({type: "situation"}, function (response) {
if(response.situation == true){
document.getElementById("grabBut").style.backgroundColor="rgba(9, 170, 55, 1)";
document.getElementById("grabBut").addEventListener("click", stop_click,false);
document.getElementById("grabBut").removeEventListener("click",start_click,false);
}
else{
document.getElementById("grabBut").style.backgroundColor="rgba(108, 108, 108, 0.75)";
document.getElementById("grabBut").addEventListener("click", start_click,false);
document.getElementById("grabBut").removeEventListener("click",stop_click,false);
}
}) ;
}
function start_click() {
document.getElementById("grabBut").style.backgroundColor="rgba(9, 170, 55, 1)";
chrome.extension.sendMessage({
type:"start"
});
document.getElementById("grabBut").addEventListener("click", stop_click,false);
document.getElementById("grabBut").removeEventListener("click",start_click,false);
};
function stop_click(){
document.getElementById("grabBut").style.backgroundColor="rgba(108, 108, 108, 0.75)";
chrome.extension.sendMessage({
type:"stop"
});
document.getElementById("grabBut").addEventListener("click", start_click,false);
document.getElementById("grabBut").removeEventListener("click",stop_click,false);
}