Rakorium-M
NGBler
- Registriert
- 14 Juli 2013
- Beiträge
- 413
Hallo,
ich hab gerade ein Greasemonkey-Script gebastelt, dass Desktop-Benachrichtigungen erstellt, wenn neue Beiträge / PNs / Ankündigungen in der Kontrollleiste auftauchen.
Getestet mit Firefox / Greasemonkey / Darkfish, vielleicht hilft's ja noch jemandem.
[src=javascript]// ==UserScript==
// ==UserScript==
// @name NGB Desktop Notification
// @version 1
// @grant GM.setValue
// @grant GM.getValue
// @include https://ngb.to/*
// @include https://www.ngb.to/*
// ==/UserScript==
function serializeNodeList(list){
return JSON.stringify(Array.from(list).map(x => x.innerHTML));
}
const emptyList = serializeNodeList([]);
setTimeout(() => {
var headerbar = document.querySelector('#toplinks');
if (Notification.permission == 'default')
Notification.requestPermission();
var lastLocalState = emptyList;
var testForNews = async function() {
var news = headerbar.querySelectorAll('li.notifications > a');
var lastnews = await GM.getValue('ngbnotify_lastnews', emptyList);
console.log(new Date().toLocaleTimeString(), news, lastnews, lastLocalState);
var localState = serializeNodeList(news);
if (lastLocalState != localState){
if (news.length && (lastnews == emptyList || localState != lastnews)){
console.log('Notify');
new Notification('NGB.to notify', {body: 'New event on ngb.to: '+Array.from(news).map(x => x.firstChild.nodeValue+' ('+x.querySelector('sup').textContent+')').join(', ')});
}
GM.setValue('ngbnotify_lastnews', localState);
}
lastLocalState = localState;
};
testForNews();
setInterval(testForNews, 30*1000 + 100);
}, 4000);
[/src]
ich hab gerade ein Greasemonkey-Script gebastelt, dass Desktop-Benachrichtigungen erstellt, wenn neue Beiträge / PNs / Ankündigungen in der Kontrollleiste auftauchen.
Getestet mit Firefox / Greasemonkey / Darkfish, vielleicht hilft's ja noch jemandem.
[src=javascript]// ==UserScript==
// ==UserScript==
// @name NGB Desktop Notification
// @version 1
// @grant GM.setValue
// @grant GM.getValue
// @include https://ngb.to/*
// @include https://www.ngb.to/*
// ==/UserScript==
function serializeNodeList(list){
return JSON.stringify(Array.from(list).map(x => x.innerHTML));
}
const emptyList = serializeNodeList([]);
setTimeout(() => {
var headerbar = document.querySelector('#toplinks');
if (Notification.permission == 'default')
Notification.requestPermission();
var lastLocalState = emptyList;
var testForNews = async function() {
var news = headerbar.querySelectorAll('li.notifications > a');
var lastnews = await GM.getValue('ngbnotify_lastnews', emptyList);
console.log(new Date().toLocaleTimeString(), news, lastnews, lastLocalState);
var localState = serializeNodeList(news);
if (lastLocalState != localState){
if (news.length && (lastnews == emptyList || localState != lastnews)){
console.log('Notify');
new Notification('NGB.to notify', {body: 'New event on ngb.to: '+Array.from(news).map(x => x.firstChild.nodeValue+' ('+x.querySelector('sup').textContent+')').join(', ')});
}
GM.setValue('ngbnotify_lastnews', localState);
}
lastLocalState = localState;
};
testForNews();
setInterval(testForNews, 30*1000 + 100);
}, 4000);
[/src]
Zuletzt bearbeitet: