Created
January 28, 2018 07:02
-
-
Save Rplus/6d2834e59e4f05cafa114ee67b75d769 to your computer and use it in GitHub Desktop.
wecatch-auto-refresh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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