Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
wecatch-auto-refresh
window.log = {};
const timeInterval = 5.5; // minute(s)
const filters = {
'/B/': 'iv80+',
'/G/': 'iv90+',
'/W/': 'iv0',
'/R/': 'iv100',
'/349.': '醜醜魚',
};
var checkGoodItems = () => {
var imgSrcs = [...document.querySelectorAll('img.leaflet-marker-icon')].map(i => i.src);
var result = Object.keys(filters).reduce((all, f) => {
all[f] = imgSrcs.filter(src => src.indexOf(f) !== -1);
return all;
}, {});
var noticeStrings = Object.keys(result)
.map(i => result[i].length ? `${filters[i]}: ${result[i].length}` : '')
.filter(Boolean);
if (noticeStrings.length) {
let n = new Notification('', { body: noticeStrings.join('\n') });
n.onshow = setTimeout(() => { n.close()}, 10000);
n.onclick = () => {
window.focus();
n.close();
};
}
window.log[new Date().toString()] = { noticeStrings, result };
};
var refresh = () => {
document.querySelector('#custom-control').click();
setTimeout(checkGoodItems, 5000);
};
var refreshTimer = setInterval(refresh, timeInterval * 60 * 1000);
refresh();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment