BBRT notifier

Nofifies new messages on the BBRT website through scraping.

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==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);
})();