forked from mudit2103/piazza-booster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopup.js
71 lines (61 loc) · 2.77 KB
/
popup.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
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
function click(e) {
switch (e.target.id) {
case 'unresolved':
chrome.tabs.executeScript(null,
{code:'followups = document.getElementsByClassName("clarifying_discussion clearFix");' +
'for (i = 0; i < followups.length; i++) {' +
'if (followups[i].className.valueOf() != "clarifying_discussion clearFix unresolved".valueOf()) {' +
'document.getElementsByClassName("clarifying_discussion clearFix")[i].style.display = "none";' +
'}' +
'}'
});
break;
case 'no-reply':
chrome.tabs.executeScript(null,
{code: 'all_replies = document.getElementsByClassName("all_replies");' +
'for (i = 0; i < all_replies.length; i++) {' +
'all_replies[i].style.display = "none";' +
'}'
});
break;
case 'reset':
chrome.tabs.executeScript(null,
{code: 'all_replies = document.getElementsByClassName("all_replies");' +
'for (i = 0; i < all_replies.length; i++) {' +
'all_replies[i].style.display = "block";' +
'}'
});
chrome.tabs.executeScript(null,
{code: 'followups = document.getElementsByClassName("clarifying_discussion clearFix");' +
'for (i = 0; i < followups.length; i++) {' +
'document.getElementsByClassName("clarifying_discussion clearFix")[i].style.display = "block";' +
'}'
});
chrome.tabs.executeScript(null,
{code: 'all_replies = document.getElementsByClassName("discussion_replies existing_reply clearFix");' +
'for (i = 0; i < all_replies.length; i++) {' +
'all_replies[i].style.display = "block";' +
'}'
});
break;
case 'see-only':
target = document.getElementById("target").value;
chrome.tabs.executeScript({
code: "filterAll('" + target + "');"
});
break;
}
window.close();
}
document.addEventListener('DOMContentLoaded', function () {
var divs = document.querySelectorAll('.option');
chrome.tabs.executeScript({
file: 'utils.js',
});
for (var i = 0; i < divs.length; i++) {
divs[i].addEventListener('click', click);
}
});