-
Notifications
You must be signed in to change notification settings - Fork 0
/
stimuli_helper.js
55 lines (46 loc) · 1.63 KB
/
stimuli_helper.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
/*
Content scripts can not access the local files directly and have to do this through the browser runtime
*/
function makeURL(img_path) {
return browser.runtime.getURL(img_path);
}
/*
Inserts the stimuli into the webpage
*/
function insertStimuli() {
var like = document.createElement("img");
like.setAttribute("src", makeURL("icons/test_like.png"));
// like.setAttribute("src", makeURL("icons/invert_like.png"));
like.className = "stimuli like";
document.body.appendChild(like);
var comment = document.createElement("img");
comment.setAttribute("src", makeURL("icons/test_on.png"));
comment.className = "stimuli comment";
// document.body.appendChild(comment);
var up = document.createElement("img");
up.setAttribute("src", makeURL("icons/test_up.png"));
up.className = "stimuli up";
document.body.appendChild(up);
var down = document.createElement("img");
down.setAttribute("src", makeURL("icons/test_down.png"));
down.className = "stimuli down";
document.body.appendChild(down);
}
function removeElement(element) {
element.remove();
}
function hideStimuli() {
hideElement(document.getElementsByClassName("like")[0]);
// hideElement(document.getElementsByClassName("comment")[0]);
hideElement(document.getElementsByClassName("up")[0]);
hideElement(document.getElementsByClassName("down")[0]);
}
/*
Display the stimuli by name
*/
function displayStimuli() {
displayElement(document.getElementsByClassName("like")[0]);
displayElement(document.getElementsByClassName("comment")[0]);
displayElement(document.getElementsByClassName("up")[0]);
displayElement(document.getElementsByClassName("down")[0]);
}