'Saviour' of Lost Souls v0.1.1: delete votes for Tinkeringbell

This commit is contained in:
Glorfindel 2018-11-25 13:08:31 +01:00
parent d79125d3d4
commit 757166b1d5

View file

@ -5,7 +5,7 @@
// @author Glorfindel // @author Glorfindel
// @updateURL https://raw.githubusercontent.com/Glorfindel83/SE-Userscripts/master/saviour-of-lost-souls/saviour-of-lost-souls.user.js // @updateURL https://raw.githubusercontent.com/Glorfindel83/SE-Userscripts/master/saviour-of-lost-souls/saviour-of-lost-souls.user.js
// @downloadURL https://raw.githubusercontent.com/Glorfindel83/SE-Userscripts/master/saviour-of-lost-souls/saviour-of-lost-souls.user.js // @downloadURL https://raw.githubusercontent.com/Glorfindel83/SE-Userscripts/master/saviour-of-lost-souls/saviour-of-lost-souls.user.js
// @version 0.1 // @version 0.1.1
// @match *://meta.stackexchange.com/questions/* // @match *://meta.stackexchange.com/questions/*
// @grant none // @grant none
// ==/UserScript== // ==/UserScript==
@ -15,8 +15,8 @@
// Check author reputation = 1 // Check author reputation = 1
let owner = $('div.post-signature.owner'); let owner = $('div.post-signature.owner');
let reputation = parseInt(owner.find('span.reputation-score')[0].innerText); let reputation = owner.find('span.reputation-score')[0].innerText;
if (reputation != 1) { if (reputation != "1") {
return; return;
} }
@ -25,6 +25,7 @@
if (myReputation < 5) { if (myReputation < 5) {
return; return;
} }
let isModerator = $("a.js-mod-inbox-button").length > 0;
// Add post menu button // Add post menu button
let question = $('#question'); let question = $('#question');
@ -88,6 +89,7 @@
url: "https://" + document.location.host + "/posts/" + postID + "/vote/3", // 3 = downvote url: "https://" + document.location.host + "/posts/" + postID + "/vote/3", // 3 = downvote
data: "fkey=" + fkey, data: "fkey=" + fkey,
success: function () { success: function () {
// TODO: set downvote button color
console.log("Downvote cast."); console.log("Downvote cast.");
}, },
error: function (jqXHR, textStatus, errorThrown) { error: function (jqXHR, textStatus, errorThrown) {
@ -103,6 +105,7 @@
url: "https://" + document.location.host + "/flags/questions/" + postID + "/close/add", url: "https://" + document.location.host + "/flags/questions/" + postID + "/close/add",
data: "fkey=" + fkey + "&closeReasonId=OffTopic&closeAsOffTopicReasonId=8", data: "fkey=" + fkey + "&closeReasonId=OffTopic&closeAsOffTopicReasonId=8",
success: function () { success: function () {
// TODO: update close vote count
console.log("Close flag/vote cast."); console.log("Close flag/vote cast.");
}, },
error: function (jqXHR, textStatus, errorThrown) { error: function (jqXHR, textStatus, errorThrown) {
@ -110,13 +113,14 @@
console.log("Error: " + textStatus + " " + errorThrown); console.log("Error: " + textStatus + " " + errorThrown);
} }
}); });
} else if (myReputation >= 20000) { } else if (myReputation >= 20000 || isModerator) {
// Delete vote // Delete vote
// TODO: only if score <= -3, maybe also if myReputation >= 10000 and question age >= 48 hours // TODO, at least for non-moderators: only if score <= -3, maybe also if myReputation >= 10000 and question age >= 48 hours
$.post({ $.post({
url: "https://" + document.location.host + "/posts/" + postID + "/vote/10", // 10 = delete url: "https://" + document.location.host + "/posts/" + postID + "/vote/10", // 10 = delete
data: "fkey=" + fkey, data: "fkey=" + fkey,
success: function () { success: function () {
// TODO: update delete vote count
console.log("Delete vote cast."); console.log("Delete vote cast.");
}, },
error: function (jqXHR, textStatus, errorThrown) { error: function (jqXHR, textStatus, errorThrown) {