Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.

Commit

Permalink
feat: add initial source
Browse files Browse the repository at this point in the history
  • Loading branch information
KillWolfVlad committed Oct 23, 2023
1 parent c8902be commit 42781ed
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/cron.yaml
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# gk-upvote

Script for auto voting on GitKraken feedback website
20 changes: 20 additions & 0 deletions package.json
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"
}
}
4 changes: 4 additions & 0 deletions suggestions.json
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"
]
44 changes: 44 additions & 0 deletions upvote.test.js
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");
});
}
});

0 comments on commit 42781ed

Please sign in to comment.