-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathsandboxed.html
104 lines (91 loc) · 2.13 KB
/
sandboxed.html
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
92
93
94
95
96
97
98
99
100
101
102
103
104
<html>
<style>
button
{
text-align: center;
background-color: #FF3333;
color:#003333;
border-top: #669999;
border-bottom: #669999;
border-left:#999999;
border-right:#999999;
border:2px solid;
padding-top: 4px;
height:50px;
width:250px;
}
body
{
background-color: #003333;
margin:0 auto;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 16px;
font-style: normal;
font-variant: normal;
font-weight: 500;
color:white;
line-height: 15px;
width:300px;
height:300px;
}
</style>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="http://www.w3schools.com/lib/w3.css">
<!-- jQuery library -->
<!--<script src="jquery.js"></script>
<script src="jqueryMin.js"> </script>-->
<body>
<form>
<button id ="rainbow" type="button"> Rainbow Mode
</button>
<button id ="picture" type="button"> Picture Mode
</button>
<button id ="single" type="button"> Single Mode
</button>
<button id="stop" type="button"> <b>Stop annihilating! </b>
</button>
</form>
</body>
<script language = "Javascript">
function getTab(callback){
chrome.tabs.query({ currentWindow: true, active: true }, function(tabs) {
console.log(tabs[0]);
callback(tabs[0]);
});
}
function createPort(tab){
var port = chrome.tabs.connect(tab.id,{name: "mode"});
document.getElementById("stop").onclick = function(){
if(mode === "off")
mode = "on";
else
mode = "off";
setMode(port);
console.log("clikityclik");
};
document.getElementById("rainbow").onclick = function(){
mode = "rainbow";
setMode(port);
};
document.getElementById("picture").onclick = function(){
mode = "picture";
setMode(port);
};
document.getElementById("single").onclick = function(){
mode = "single";
setMode(port);
};
console.log(mode);
}
function setMode(port){
/*sends message to port*/
if(port)
port.postMessage({newMode: mode});
else{
console.log("error: port not created");
}
}
var mode = "on"; //mode is preset to on in content.js
getTab(createPort);
</script>
</html>