Atelier 801 new messages notifications

This script notifies of unread messages on the Atelier 801 website (atelier801.com) in the browser and is a temporary solution until this website officially has support for browser notifications.

目前為 2020-02-27 提交的版本,檢視 最新版本

// ==UserScript==
// @name           Atelier 801 new messages notifications
// @name:ru        Оповещение о новых сообщениях на Atelier 801
// @namespace      https://gf.qytechs.cn/ru/users/155145-inlifeuser
// @version        2020.02.27
// @description    This script notifies of unread messages on the Atelier 801 website (atelier801.com) in the browser and is a temporary solution until this website officially has support for browser notifications.
// @description:ru Этот скрипт уведомляет о непрочитанных сообщениях на сайте Atelier 801 (atelier801.com) в браузере и является временным решением, пока на этом сайте официально нету поддержки браузерных уведомлений.
// @author         Inlifeuser
// @license        MIT
// @include        *
// @grant          GM_addValueChangeListener
// @grant          GM_getValue
// @grant          GM_setValue
// @grant          GM_xmlhttpRequest
// @grant          GM_notification
// @connect        atelier801.com
// ==/UserScript==

'use strict';

var checkInterval = 300; // In seconds

var notificationLink = 'https://atelier801.com/conversations';

function getTimestamp () {
  return Date.now() / 1000 | 0
}

function checkConversations () {
  if (getTimestamp() - GM_getValue("atelier801NewMessagesNotificationsLastCheckTimestamp") >= checkInterval) {
    GM_setValue("atelier801NewMessagesNotificationsLastCheckTimestamp", getTimestamp());
    GM_xmlhttpRequest({
      method: "GET",
      url: "https://atelier801.com/index",
      onload: function (response) {
        var unreadMessagesCount = (this.responseText.match(/<a href="\/conversations">(\d+)/i) || [])[1];
        if (unreadMessagesCount) {
          var websiteLanguage = (this.responseText.match(/<input type="hidden" id="langue_principale" name="langue_principale" value="(.*?)">/i) || [])[1];
          if (websiteLanguage === 'ru') {
            GM_notification({text: "Новых сообщений: " + unreadMessagesCount, title: "Оповещение о новых сообщениях на Atelier 801 (UserScript)", onclick: function () { window.open(notificationLink); }});
          } else {
            GM_notification({text: unreadMessagesCount + " new message(s)", title: "Atelier 801 new messages notifications (UserScript)", onclick: function () { window.open(notificationLink); }});
          }
        }
      }
    });
  }
};

(function () {
  GM_addValueChangeListener("atelier801NewMessagesNotificationsLastCheckTimestamp");

  if (GM_getValue("atelier801NewMessagesNotificationsLastCheckTimestamp") === undefined) {
    GM_setValue("atelier801NewMessagesNotificationsLastCheckTimestamp", 0);
  }

  checkConversations();
  setInterval(checkConversations, checkInterval + '000');
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址