aboutsummaryrefslogtreecommitdiff
path: root/static
diff options
context:
space:
mode:
authorr <r@freesoftwareextremist.com>2020-09-03 06:26:32 +0000
committerr <r@freesoftwareextremist.com>2020-09-03 06:29:03 +0000
commit7a59d010f6d07bcfb074e60f1f06b002c4bf7b74 (patch)
treee39adf5e43b74a2c2c66e7e5b38592108b6545f3 /static
parent28695fb8e6b299389347fc8c42f7dc3923b42f24 (diff)
downloadbloat-7a59d010f6d07bcfb074e60f1f06b002c4bf7b74.tar.gz
bloat-7a59d010f6d07bcfb074e60f1f06b002c4bf7b74.zip
Fix issues related to AntiDopamine mode
- Add AntiDopamine mode description - Update fluoride to support AntiDopamine mode
Diffstat (limited to 'static')
-rw-r--r--static/fluoride.js25
1 files changed, 20 insertions, 5 deletions
diff --git a/static/fluoride.js b/static/fluoride.js
index 6c51694..e055b6d 100644
--- a/static/fluoride.js
+++ b/static/fluoride.js
@@ -7,11 +7,19 @@ var reverseActions = {
"unretweet": "retweet"
};
-function getCSRFToken() {
+var csrfToken = "";
+var antiDopamineMode = false;
+
+function checkCSRFToken() {
var tag = document.querySelector("meta[name='csrf_token']");
if (tag)
- return tag.getAttribute("content");
- return "";
+ csrfToken = tag.getAttribute("content");
+}
+
+function checkAntiDopamineMode() {
+ var tag = document.querySelector("meta[name='antidopamine_mode']");
+ if (tag)
+ antiDopamineMode = tag.getAttribute("content") === "true";
}
function http(method, url, body, type, success, error) {
@@ -50,11 +58,13 @@ function handleLikeForm(id, f) {
updateActionForm(id, forms[i], reverseActions[action]);
}
- var body = "csrf_token=" + encodeURIComponent(getCSRFToken());
+ var body = "csrf_token=" + encodeURIComponent(csrfToken);
var contentType = "application/x-www-form-urlencoded";
http("POST", "/fluoride/" + action + "/" + id,
body, contentType, function(res, type) {
+ if (antiDopamineMode)
+ return;
var data = JSON.parse(res);
var count = data.data;
if (count === 0)
@@ -87,11 +97,13 @@ function handleRetweetForm(id, f) {
updateActionForm(id, forms[i], reverseActions[action]);
}
- var body = "csrf_token=" + encodeURIComponent(getCSRFToken());
+ var body = "csrf_token=" + encodeURIComponent(csrfToken);
var contentType = "application/x-www-form-urlencoded";
http("POST", "/fluoride/" + action + "/" + id,
body, contentType, function(res, type) {
+ if (antiDopamineMode)
+ return;
var data = JSON.parse(res);
var count = data.data;
if (count === 0)
@@ -193,6 +205,9 @@ function handleStatusLink(a) {
}
document.addEventListener("DOMContentLoaded", function() {
+ checkCSRFToken();
+ checkAntiDopamineMode();
+
var statuses = document.querySelectorAll(".status-container");
for (var i = 0; i < statuses.length; i++) {
var s = statuses[i];