BS Check

Desktopbenachrichtigung bei neuer Folge einer favorisierten Serie!

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         BS Check
// @namespace    http://tampermonkey.net/
// @version      2.1.1
// @description  Desktopbenachrichtigung bei neuer Folge einer favorisierten Serie!
// @author       Asu_nyan
// @match        https://bs.to/
// @match        https://burningseries.co/
// @grant        none
// @icon         https://bs.to/favicon.ico
// ==/UserScript==
// jshint esversion: 6

(function() {
    'use strict';
    check();
})();
function getFavLinks() {
    const names = Array.from(document.querySelectorAll('#other-series-nav > ul a')).map(el => el.href);
    return names.slice(0, names.length-2);
}
async function getNELinks() {
    const data = await fetch(window.location.origin).then(res => res.text());
    const div = document.createElement('div');
    div.innerHTML = data;
    let list = div.querySelectorAll('#newest_episodes > div > ul a');
    return Array.from(list).map(el => el.href);
}
function getShowRoot(url) {
    return url.split('/').slice(0, 5).join('/');
}
async function check() {
    let bsne = (window.localStorage.bsne) ? JSON.parse(window.localStorage.bsne) : [];
    (bsne.length > 40) ? bsne.splice(0, 20) : bsne;
    const fav_list = getFavLinks();
    const ne_list = await getNELinks();
    const filtered = ne_list.filter(e => fav_list.includes(getShowRoot(e)) && !bsne.includes(e));
    if(filtered.length) {
        filtered.forEach(async el => {
            const data = await fetch(el).then(res => res.text());
            const div = document.createElement('div');
            div.innerHTML = data;
            const cover = div.querySelector('img[alt="Cover"]').src;
            const title = div.querySelector('#sp_left > h2').textContent.split('Staffel')[0].trim()
            const options = { body: title, icon: cover };
            let n = new Notification('Neue Folge verfügbar!', options);
            n.href=el;
            n.onclick=function onclick(event){
                window.open(el);
                event.target.close();
            };
        });
        bsne = bsne.concat(filtered);
        window.localStorage.bsne = JSON.stringify(bsne);
    }
    setTimeout(check, 1000*60);
}