BBRT notifier

Nofifies new messages on the BBRT website through scraping.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         BBRT notifier
// @namespace    http://blog.regularoddity.com/
// @version      0.3
// @description  Nofifies new messages on the BBRT website through scraping.
// @author       E E
// @match        https://www.barebackrt.com/members/default.php
// @icon         https://www.barebackrt.com/favicon.ico
// @grant        GM_notification
// @license      MIT License
// ==/UserScript==

/* esversion: 6 */

(function() {
    'use strict';
    let messages = 0;
    const Query = 'emailLogo';


    let getNode = function() {
        let doc = top.window.frames[1].document.children[0];
        let xpath = document.evaluate('//span[@id="emailLogo"]', doc);
        return xpath.iterateNext();
    };

    setInterval(function() {
        let node = getNode();
        let count;
        if (!node) {
            count = 0;
        } else {
            let text = node.textContent;
            text = text.substring(1);
            count = parseInt(text);
        }
        if (count > messages) {
            GM_notification(
                count === 1 ? 'There is a message on BBRT.'
                    : `There are ${count} messages on BBRT.`);
        }
        messages = count;
    }, 2000);
})();