ExEveryDay

It is the dawn of a new day!

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         ExEveryDay
// @namespace    https://github.com/FlandreDaisuki
// @description  It is the dawn of a new day!
// @version      1.0
// @author       FlandreDaisuki
// @match        https://exhentai.org/*
// @match        https://e-hentai.org/*
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        GM_xmlhttpRequest
// @connect      *
// @license      MIT
// @noframes
// ==/UserScript==

const DAY_MS = 86400 * 1e3;

class Cookie {
  constructor(cookie = document.cookie) {
    this.map = document.cookie.split('; ')
      .reduce((c, s) => {
      const i = s.indexOf('=');
      c.set(s.slice(0, i), s.slice(i + 1));
      return c;
    }, new Map());
  }

  get id() {
    return this.map.get('ipb_member_id');
  }

  toString() {
    return [...this.map.entries()]
      .map(([k, v]) => `${k}=${v}`)
      .join('; ');
  }
}

const cookie = new Cookie;

const lastDate = new Date(GM_getValue(cookie.id, new Date().toJSON()));
const dateDiff = Date.now() - lastDate;

const onerror = (resp) => {
  console.error('ExEveryDay', resp);
}

const onload = (resp) => {
  console.info('ExEveryDay', resp);
  if(resp.responseText.match(/It is the dawn of a new day/g)) {
    GM_setValue(cookie.id, new Date().toJSON());
  }
}

if(dateDiff > DAY_MS || dateDiff === 0) {
  GM_xmlhttpRequest({
    method: 'GET',
    url: 'https://e-hentai.org/news.php',
    headers: {
      Cookie: cookie.toString(),
    },
    onload,
    onerror,
  });
}