Activity instead of promos

Makes the inbox button link directly to activity, marks all gifts as read, keeping the number of notifications in the red dot equal to the number of unread activity (old number - promos = only activity).

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Activity instead of promos
// @namespace    https://dreamdb.com/
// @version      20240701.3
// @description  Makes the inbox button link directly to activity, marks all gifts as read, keeping the number of notifications in the red dot equal to the number of unread activity (old number - promos = only activity).
// @author       ajcrwl
// @match        https://tapas.io/*
// @match        https://m.tapas.io/*
// @icon         data:image/gif;base64,R0lGODlhJgAmALMPAPyln/dediYmJvmvz/r09Ph/j5KSkv7ZvPvW89PT0//t1fyZWvZGVgAAAP///wAAACH/C1hNUCBEYXRhWE1QPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNi4wLWMwMDYgNzkuZGFiYWNiYiwgMjAyMS8wNC8xNC0wMDozOTo0NCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1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mAAAE//DJSau9OOvNu/+WI45kSYKPeBRB675wMRCO5wxMru98D4ibW29IzBVqGWFxyfslmdAd7aJkIFSMAM0BYAxEigDRGSrkvocv4Lp2HNOOw1muO1LFXsdCe0Ao8gd6Vn9edDkBSBUOeGpoCARtgQc/Cl8jdIhUZllXBAQrNAp6nZ9zO3YhOEYFV3sFa38FMlymOl8YDoc0kHkOCgtWDrxEiSFRUbe4AsdLycoNm8w7gUECDQ4ILMcBr0DV1ybhDeAnHA7W4eICxTbW4+MGJAbv4+soKe7v6yP59ewd58ARgOdpnoAEIhrYQxFwxDx6DeIlXAiioUN3B0ko/GcOXboSGy7vWfw4IiRDawhJOkhgsuJAiDDpIbyXgoCAmzhz5vRGU2U5mkCDCh1KtKhRoREAADs=
// @grant        none
// @license      CC BY-NC-SA 4.0
// ==/UserScript==

const style = 'color: black; background: orange; font-weight: bold;padding:5px;';

var a = document.querySelector('a.js-tiara-tracking-nav[href="/inbox/gift"]');
var a2 = document.querySelector('a.relative[href="/inbox/gift"]');
var sauce;

 if (a) {sauce = a;}
if (a2) {sauce = a2;}
//console.log('%c ', style, sauce);

if (sauce) {
    sauce.setAttribute('href', '/activities');
    if (a2) { var dot = sauce.querySelector('div'); } else {
    dot = sauce.querySelector('.js-new-dot');}
    if (dot) { //if dot element exists
        var mesloc = 'https://' + window.location.host + '/inbox/message';
        //send xhr to grab promos page
        const mxhr = new XMLHttpRequest();
        mxhr.open("GET", mesloc);
        mxhr.send();
        mxhr.responseType = "text";
        mxhr.onload = () => {
            //on success look for NEW badges
            if (mxhr.readyState == 4 && mxhr.status == 200) {
                const data = mxhr.response;
                console.log('%cnew promos: ',style,data.includes('<div class="badge--new">'));
                if (data.includes('<div class="badge--new">')) {
                    //send request to mark promos as read
                    const xhr = new XMLHttpRequest();
                    xhr.open("PATCH", "https://tapas.io/inbox/message/messages/mark-viewed");
                    xhr.setRequestHeader("Content-type", "application/json;charset=UTF-8");
                    const body = JSON.stringify({
                        body: "friendly userscript clearing unread promo messages",
                    });
                    xhr.onload = () => {
                        var data = JSON.parse(xhr.responseText);
                        if (xhr.readyState == 4 && xhr.status == "200") {
                            console.log('%cpatch success, will reload now',style);
                            location.reload();
                            //move window reload here?
                        } else {
                            console.log(`Error: ${xhr.status}`);
                        }
                    };
                    xhr.send(body);
                } else {console.log('%cno new promos! check activity.',style)} //no new promos so all numbers are for new activities
            } else { //failed to fetch promos page
                console.log(`Error: ${mxhr.status}`);
            }
        };
        console.log('%cafter message req',style);
    } else { console.log("%cdot is empty!",style);} //no new notifs
} else {console.log('%cno inbox button??',style);} //not logged in, so no button