This repository has been archived by the owner on Dec 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c8902be
commit 42781ed
Showing
5 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: cron | ||
|
||
on: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: "*/55 * * * *" # every 55th minute | ||
|
||
jobs: | ||
############################################################################## | ||
upvote: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: lts/* | ||
|
||
- run: yarn run test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
# gk-upvote | ||
|
||
Script for auto voting on GitKraken feedback website |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "gk-upvote", | ||
"version": "0.0.0-development", | ||
"private": true, | ||
"description": "Script for auto voting on GitKraken feedback website", | ||
"homepage": "https://github.com/KillWolfVlad/gk-upvote#readme", | ||
"bugs": { | ||
"url": "https://github.com/KillWolfVlad/gk-upvote/issues" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/KillWolfVlad/gk-upvote.git" | ||
}, | ||
"license": "UNLICENSED", | ||
"author": "KillWolfVlad", | ||
"type": "module", | ||
"scripts": { | ||
"test": "node --test" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[ | ||
"https://feedback.gitkraken.com/suggestions/191565/support-sshconfig-file", | ||
"https://feedback.gitkraken.com/suggestions/194039/support-multiple-gitkraken-windows" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import assert from "node:assert"; | ||
import { describe, it } from "node:test"; | ||
|
||
import suggestions from "./suggestions.json" assert { type: "json" }; | ||
|
||
describe("Upvote", () => { | ||
for (const suggestion of suggestions) { | ||
it(suggestion, async () => { | ||
const feedbackId = suggestion.match(/\/suggestions\/(\d+)\//)[1]; | ||
|
||
const htmlResponse = await fetch( | ||
`https://feedback.gitkraken.com/suggestions/${encodeURIComponent( | ||
feedbackId | ||
)}` | ||
); | ||
|
||
const html = await htmlResponse.text(); | ||
|
||
const csrfToken = html.match( | ||
/<input type="hidden" name="csrf_token" value="(.*)">/ | ||
)[1]; | ||
|
||
const formData = new FormData(); | ||
|
||
formData.append("csrf_token", csrfToken); | ||
formData.append("ts", new Date().getTime()); | ||
|
||
const toggleUpvoteResult = await fetch( | ||
`https://feedback.gitkraken.com/s/${encodeURIComponent( | ||
feedbackId | ||
)}/toggleupvote`, | ||
{ | ||
method: "POST", | ||
body: formData, | ||
headers: { | ||
cookie: htmlResponse.headers.getSetCookie().join(";"), | ||
}, | ||
} | ||
).then((response) => response.text()); | ||
|
||
assert.strictEqual(toggleUpvoteResult, "OK"); | ||
}); | ||
} | ||
}); |