Asspig notifier

Nofifies new messages on the Asspig website through scraping.

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Asspig notifier
// @namespace    http://blog.regularoddity.com/
// @version      1.1
// @description  Nofifies new messages on the Asspig website through scraping.
// @author       E E
// @match        https://www.asspig.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=asspig.com
// @grant        GM_notification
// @license      GPLv3
// ==/UserScript==

/* jshint esversion: 6 */

(function() {
    'use strict';
    let messages = 0;
    const Query = '#link_messenger span';

    setInterval(function() {
        let element = document.querySelector(Query);
        if (!element) {
            return;
        }
        element = element.textContent;
        let count = element.length === 0 ? 0 : parseInt(element);
        if (count > messages) {
            GM_notification(count === 1 ? 'There is a message on Asspig.'
                : `There are ${count} messages on Asspig.`);
        }
        messages = count;
    }, 2000);
})();