Skip to content

Commit d09f1bf

Browse files
committed
userLists feature added
1 parent 67c74f2 commit d09f1bf

File tree

7 files changed

+48
-2
lines changed

7 files changed

+48
-2
lines changed

src/background.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
chrome.runtime.onInstalled.addListener(() => {
33
chrome.storage.sync.set({
44
'blogEntries': true,
5-
'problemset': true
5+
'problemset': true,
6+
'userLists': ''
67
});
78
});

src/blogEntries.js

-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ chrome.storage.sync.get('blogEntries', function(data){
3939
},
4040
// prevent form submit
4141
keydown : function(event) {
42-
4342
if (event.keyCode == 13) {
4443
event.preventDefault();
4544
return false;

src/manifest.json

+17
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,23 @@
5252
"https://*.codeforces.com/contest/*/problem/*"
5353
],
5454
"run_at": "document_idle"
55+
},
56+
{
57+
"all_frames": false,
58+
"js": [
59+
"./scripts/jquery-3.6.0.min.js",
60+
"userLists.js"
61+
],
62+
"matches": [
63+
"https://*.codeforces.com/problemset",
64+
"https://*.codeforces.com/problemset/status",
65+
"https://*.codeforces.com/problemset/standings",
66+
"https://*.codeforces.com/problemsets/acmsguru",
67+
"https://*.codeforces.com/problemsets/acmsguru/status",
68+
"https://*.codeforces.com/problemsets/acmsguru/standings",
69+
"https://*.codeforces.com/contests"
70+
],
71+
"run_at": "document_start"
5572
}
5673
]
5774
}

src/popup/popup.css

+4
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,8 @@ h1, h2{
5757

5858
input[type="checkbox"] {
5959
float: right;
60+
}
61+
62+
input[type="text"] {
63+
width: 120px;
6064
}

src/popup/popup.html

+4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ <h2 class="title">Toggle features</h2>
2727
<span class="name">customize problemset problems page</span>
2828
<input id="problemset" type="checkbox">
2929
</li>
30+
<li>
31+
<span class="name">Use List (leave empty for none)</span><br>
32+
List Key: <input id="userLists" type="text">
33+
</li>
3034
</ul>
3135
</div>
3236
</div>

src/popup/popup.js

+12
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,16 @@ $(document).ready(function(){
1616
save[String(event.target.id)] = val;
1717
chrome.storage.sync.set(save);
1818
});
19+
20+
// sync userList state
21+
chrome.storage.sync.get('userLists', function(data){
22+
$('#userLists').val(data.userLists);
23+
});
24+
25+
// set userList
26+
$('#userLists').keydown(function(event){
27+
if (event.keyCode == 13) {
28+
chrome.storage.sync.set({'userLists': $('#userLists').val()});
29+
}
30+
});
1931
});

src/userLists.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
chrome.storage.sync.get('userLists', function(data){
2+
// if no userList set, return, else inject script
3+
if(data.userLists=='') {
4+
return;
5+
}
6+
const currentURL = window.location.href;
7+
var listURL = currentURL + '?list=' + data.userLists;
8+
window.location.replace(listURL); //redirect using list
9+
});

0 commit comments

Comments
 (0)