forked from Glorfindel83/SE-Userscripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfollow-from-review.user.js
39 lines (38 loc) · 1.75 KB
/
follow-from-review.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// ==UserScript==
// @name Stack Exchange Follow From Review
// @version 0.1
// @description Temporary workaround for following posts from the review queues
// @author Glorfindel
// @updateURL https://raw.githubusercontent.com/Glorfindel83/SE-Userscripts/master/follow-from-review/follow-from-review.user.js
// @downloadURL https://raw.githubusercontent.com/Glorfindel83/SE-Userscripts/master/follow-from-review/follow-from-review.user.js
// @match *://*.stackexchange.com/review*
// @match *://*.stackoverflow.com/review*
// @match *://*.superuser.com/review*
// @match *://*.serverfault.com/review*
// @match *://*.askubuntu.com/review*
// @match *://*.stackapps.com/review*
// @match *://*.mathoverflow.net/review*
// @grant none
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
// ==/UserScript==
/* global $, waitForKeyElements */
waitForKeyElements("button.js-follow-post", function(jNode) {
$(jNode).click(function () {
let following = $(jNode).text() == "following";
let postID = $(this).attr("id").split("-")[1];
let fkey = window.localStorage["se:fkey"].split(",")[0];
// Simulate 'follow' / 'unfollow' call
$.post({
url: "https://" + document.location.host + "/posts/" + postID + "/vote/21" + (following ? "?undo=true" : ""), // 21 = follow
data: "fkey=" + fkey,
success: function () {
// Update button text to indicate success
$(jNode).text(following ? "follow" : "following");
},
error: function (jqXHR, textStatus, errorThrown) {
window.alert("An error occurred, please try again later.");
console.log("Error: " + textStatus + " " + errorThrown);
}
});
});
});