SSC Subscriptions

Adds a button on "Following" page to open all watched threads with new posts in new tabs

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name        SSC Subscriptions
// @description Adds a button on "Following" page to open all watched threads with new posts in new tabs
// @namespace   https://www.skyscrapercity.com/watched/
// @icon        https://images.platforum.cloud/icons/skyscrapercity_comx32.ico
// @include     https://www.skyscrapercity.com/watched/*
// @include     https://www.skyscrapercity.com/whats-new/posts/*
// @require     http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @grant       GM.openInTab
// @version     1.1.2
// @author      toonczyk
// ==/UserScript==

(function() {
    'use strict';

    const newNode = document.createElement('span');
    newNode.setAttribute ('class', 'unreadContainer');

    function recalculateElCount() {
        const elCount = $('div.structItem.is-unread').size();
        if (elCount > 0) {
            newNode.innerHTML = '<button class="unreadButton button california-following-normal button" type="button">Open unread (<strong>' + elCount +'</strong>) in new tabs 💬</button>';
        } else {
            newNode.innerHTML = '<span>No new posts.</span>';
        }
    }

    recalculateElCount();

    $('div.california-outer-upper-nav').append(newNode);

    const newPostNavDiv = $('div.california-upper-page-nav');
    if (newPostNavDiv.size()) {
        $(newNode).insertBefore(newPostNavDiv);
    }

    $('.unreadButton').click(function(e) {
        e.preventDefault();
        $('div.structItem.is-unread').each(function(idx, el) {
            const div = $(el);
            const href = div.find('.structItem-title a').prop('href');
            if (href.match(/\/unread$/)) {
                GM.openInTab(href);
                div.removeClass('is-unread');
            }
        });
        recalculateElCount();
    });
})();