mirror of
https://gitea.phreedom.club/localhost_frssoft/bloat.git
synced 2024-11-22 23:13:00 +00:00
Fix issues related to AntiDopamine mode
- Add AntiDopamine mode description - Update fluoride to support AntiDopamine mode
This commit is contained in:
parent
28695fb8e6
commit
7a59d010f6
@ -23,7 +23,7 @@ type Notification struct {
|
||||
}
|
||||
|
||||
// GetNotifications return notifications.
|
||||
func (c *Client) GetNotifications(ctx context.Context, pg *Pagination, excludes ...string) ([]*Notification, error) {
|
||||
func (c *Client) GetNotifications(ctx context.Context, pg *Pagination, excludes []string) ([]*Notification, error) {
|
||||
var notifications []*Notification
|
||||
params := url.Values{}
|
||||
for _, exclude := range excludes {
|
||||
|
@ -9,7 +9,7 @@ type Settings struct {
|
||||
AutoRefreshNotifications bool `json:"auto_refresh_notifications"`
|
||||
FluorideMode bool `json:"fluoride_mode"`
|
||||
DarkMode bool `json:"dark_mode"`
|
||||
AntiDopamineMode bool `json:"anti_dopamine_mode"`
|
||||
AntiDopamineMode bool `json:"anti_dopamine_mode"`
|
||||
}
|
||||
|
||||
func NewSettings() *Settings {
|
||||
|
@ -6,13 +6,13 @@ import (
|
||||
)
|
||||
|
||||
type Context struct {
|
||||
HideAttachments bool
|
||||
MaskNSFW bool
|
||||
FluorideMode bool
|
||||
ThreadInNewTab bool
|
||||
DarkMode bool
|
||||
CSRFToken string
|
||||
UserID string
|
||||
HideAttachments bool
|
||||
MaskNSFW bool
|
||||
FluorideMode bool
|
||||
ThreadInNewTab bool
|
||||
DarkMode bool
|
||||
CSRFToken string
|
||||
UserID string
|
||||
AntiDopamineMode bool
|
||||
}
|
||||
|
||||
|
@ -410,12 +410,11 @@ func (svc *service) ServeNotificationPage(c *model.Client, maxID string,
|
||||
Limit: 20,
|
||||
}
|
||||
|
||||
dope := c.Session.Settings.AntiDopamineMode
|
||||
if dope {
|
||||
excludes = append(excludes, "follow", "favourite", "reblog")
|
||||
if c.Session.Settings.AntiDopamineMode {
|
||||
excludes = []string{"follow", "favourite", "reblog"}
|
||||
}
|
||||
|
||||
notifications, err := c.GetNotifications(ctx, &pg, excludes...)
|
||||
notifications, err := c.GetNotifications(ctx, &pg, excludes)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
@ -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];
|
||||
|
@ -10,6 +10,9 @@
|
||||
{{if .CSRFToken}}
|
||||
<meta name="csrf_token" content="{{.CSRFToken}}">
|
||||
{{end}}
|
||||
{{if $.Ctx.AntiDopamineMode}}
|
||||
<meta name="antidopamine_mode" content="{{$.Ctx.AntiDopamineMode}}">
|
||||
{{end}}
|
||||
{{if .AutoRefresh}}
|
||||
<meta http-equiv="refresh" content="30">
|
||||
{{end}}
|
||||
|
@ -37,14 +37,14 @@
|
||||
<input id="fluoride-mode" name="fluoride_mode" type="checkbox" value="true" {{if .Settings.FluorideMode}}checked{{end}}>
|
||||
<label for="fluoride-mode"> Enable <abbr title="Enable JavaScript based functionality, e.g., like/retweet without page reload and reply preview on thread page">fluoride mode</abbr> </label>
|
||||
</div>
|
||||
<div class="settings-form-field">
|
||||
<input id="dark-mode" name="dark_mode" type="checkbox" value="true" {{if .Settings.DarkMode}}checked{{end}}>
|
||||
<label for="dark-mode"> Use dark theme </label>
|
||||
</div>
|
||||
<div class="settings-form-field">
|
||||
<input id="anti-dopamine-mode" name="anti_dopamine_mode" type="checkbox"
|
||||
value="true" {{if .Settings.AntiDopamineMode}}checked{{end}}>
|
||||
<label for="anti-dopamine-mode"> Remove addictive social media features </label>
|
||||
<label for="anti-dopamine-mode"> Enable <abbr title="Remove like/retweet/unread notification count and disable like/retweet/follow notifications">anti-dopamine mode</abbr> </label>
|
||||
</div>
|
||||
<div class="settings-form-field">
|
||||
<input id="dark-mode" name="dark_mode" type="checkbox" value="true" {{if .Settings.DarkMode}}checked{{end}}>
|
||||
<label for="dark-mode"> Use dark theme </label>
|
||||
</div>
|
||||
<button type="submit"> Save </button>
|
||||
</form>
|
||||
|
Loading…
Reference in New Issue
Block a user