Skip to content

Commit

Permalink
fix group and indie votes. Disable comment voting.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kunniii committed Jun 8, 2023
1 parent ba8cae6 commit 05309fb
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 39 deletions.
18 changes: 3 additions & 15 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
# New release 🎉 🎉

Hotfix for V2.2.3

I did not test the version before release.... fuk, now the chrome extension store will have to wait twice as long.

---

New update aims to ACTUALLY fix error when executing `atob()`.

New function to vote comments.
Hotfix for V2.2.5

## Changes

- Resolve #4: Fails when convert base64 to string.
- New feature: Up vote for comments
- Small change in coloring
- Fixed CORS request.
- Disable up vote comments due to limited request.

## Todo

- [x] Automation for publishing to Chrome Store.
- [ ] Show alert telling user to send email if there is some critical error.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
"@babel/core": "^7.21.8",
"@babel/preset-env": "^7.21.5"
},
"version": "2.2.5"
"version": "2.2.6"
}
12 changes: 7 additions & 5 deletions src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ const clog = console.log;
let ednTabId = 0;

const last_window_info = {
lastLocation: {},
location_default: {
height: 400,
width: 385,
width: 337,
top: 100,
left: 100,
},
Expand Down Expand Up @@ -68,7 +69,7 @@ async function launchExtension(tab) {
return;
} else {
ednTabId = tab.id;
chrome.scripting.executeScript({
await chrome.scripting.executeScript({
target: { tabId: tab.id },
files: ["ready.js"],
});
Expand All @@ -77,15 +78,16 @@ async function launchExtension(tab) {
if (found) {
extensionView.focus();
} else {
console.log(location);
chrome.windows.create(
{
url: chrome.runtime.getURL("index.html"),
type: "popup",
focused: true,
...location,
},
(w) => {
extensionView.window = w;
(window) => {
extensionView.window = window;
}
);
}
Expand All @@ -97,7 +99,7 @@ chrome.windows.onBoundsChanged.addListener((window) => {
if (extensionView.window.id === window.id) {
let location = {
height: 400,
width: 385,
width: 337,
top: window.top,
left: window.left,
};
Expand Down
40 changes: 25 additions & 15 deletions src/gradeComments.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,25 +55,35 @@ function grade_comments(stars = 4) {
.then((d) => d.json())
.then((d) => {
let comments = d.comments.items;
let timeout = 500;
let availableRequestInTwoMin = 5;
for (let comment of comments) {
let commentId = comment._id;
let name = comment.writer.name;
if (myId == comment.writer._id) continue;
post("https://fugw-edunext.fpt.edu.vn/api/comment/up-votes", {
...options,
body: JSON.stringify({
typeStar: 1,
cqId: privateCqId,
commentId: commentId,
star: stars,
}),
}).then((d) => {
if (d.status == 200) {
showIndicate(`Voted ${stars} ⭐ for ${name}`, "#059669", 2);
} else {
showIndicate(`FAIL! ${name}`, "#E32E10", 2);
}
});
// showIndicate(`Pending ⭐ for ${name}`, "#7e22ce", 2);
setTimeout(() => {
post("https://fugw-edunext.fpt.edu.vn/api/comment/up-votes", {
...options,
body: JSON.stringify({
typeStar: 1,
cqId: privateCqId,
commentId: commentId,
star: stars,
}),
}).then((d) => {
if (d.status == 200) {
showIndicate(`Voted ${stars} ⭐ for ${name}`, "#059669", 2);
} else {
showIndicate(`FAIL! ${name}`, "#E32E10", 2);
}
});
}, timeout);
availableRequestInTwoMin--;
if (!availableRequestInTwoMin) {
return;
}
// timeout += 2000;
}
});
});
Expand Down
11 changes: 10 additions & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
></div>
<div
id="app"
class="w-96"
class="w-80"
>
<img
src="icon.png"
Expand Down Expand Up @@ -66,12 +66,21 @@ <h1 class="font-bold text-lg text-white">Groups</h1>
class="group border-gray-300 border-2 rounded-lg mx-2 my-2 py-4 px-5 flex justify-between"
>
<h1 class="font-bold text-lg text-white">Comments</h1>
<!-- disabled
<button
id="comments-button"
class="bg-emerald-500 hover:scale-110 duration-100 font-bold text-white text-lg w-fit rounded-lg px-10"
>
GRADE
</button>
-->
<button
id="comments-button"
class="bg-gray-500 duration-100 font-bold text-white text-lg w-fit rounded-lg px-10"
disabled
>
GRADE
</button>
</div>
<div
id="version"
Expand Down
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "EDN Auto V2",
"description": "Automate grading tasks on edunext system ",
"version": "2.2.5",
"version": "2.2.6",
"manifest_version": 3,
"icons": {
"128": "icon.png"
Expand Down
1 change: 0 additions & 1 deletion src/ready.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ function post(url, options, params) {

const options = {
headers: {
authority: "fugw-edunext.fpt.edu.vn",
accept: "application/json, text/plain, */*",
"content-type": "application/json",
authorization: `Bearer ${token}`,
Expand Down

0 comments on commit 05309fb

Please sign in to comment.