Linter (npm install test)
This commit is contained in:
parent
7d96fbd01b
commit
0630910e9a
5 changed files with 128 additions and 58 deletions
|
@ -17,28 +17,28 @@
|
|||
// ==/UserScript==
|
||||
|
||||
(function () {
|
||||
'use strict';
|
||||
if (Notification.permission !== 'granted') {
|
||||
"use strict";
|
||||
if (Notification.permission !== "granted") {
|
||||
Notification.requestPermission();
|
||||
}
|
||||
|
||||
|
||||
// Determine site name
|
||||
var host = window.location.host;
|
||||
var sitename = host.split('.')[0];
|
||||
|
||||
var sitename = host.split(".")[0];
|
||||
|
||||
// Determine current amount of flags
|
||||
var currentTitle = $('title').text();
|
||||
var currentTitle = $("title").text();
|
||||
var currentFlags = parseInt(currentTitle);
|
||||
console.log("Current: " + currentFlags);
|
||||
|
||||
|
||||
setInterval(function () {
|
||||
var url = 'https://' + host + '/admin/dashboard?filtered=false';
|
||||
var url = "https://" + host + "/admin/dashboard?filtered=false";
|
||||
console.log("Calling: " + url);
|
||||
$.get(url, function (data) {
|
||||
var updatedTitle = $('<html/>').html(data).find('title').text();
|
||||
var updatedTitle = $("<html/>").html(data).find("title").text();
|
||||
var updatedFlags = parseInt(updatedTitle);
|
||||
console.log("Update: " + updatedFlags);
|
||||
|
||||
|
||||
// TODO: check on flag IDs instead
|
||||
if (updatedFlags < currentFlags) {
|
||||
console.log("Less flags.");
|
||||
|
@ -47,14 +47,14 @@
|
|||
} else if (updatedFlags > currentFlags) {
|
||||
console.log("More flags.");
|
||||
// new flags, create a notification. Remember the current number, so that we don't send a notification twice for the same flag
|
||||
currentFlags = updatedFlags;
|
||||
if (Notification.permission === 'granted') {
|
||||
var notification = new Notification('New flags (total: ' + updatedFlags + ')', {
|
||||
icon: 'https://cdn.sstatic.net/Sites/' + sitename + '/img/apple-touch-icon.png',
|
||||
currentFlags = updatedFlags;
|
||||
if (Notification.permission === "granted") {
|
||||
var notification = new Notification("New flags (total: " + updatedFlags + ")", {
|
||||
icon: "https://cdn.sstatic.net/Sites/" + sitename + "/img/apple-touch-icon.png",
|
||||
requireInteraction: true // on macOS, this only has effect when you set the notification types of your browser to 'Alert' instead of 'Banner'.
|
||||
});
|
||||
console.log("Notification created.");
|
||||
notification.onclick = function() {
|
||||
notification.onclick = function () {
|
||||
console.log("Notification clicked.");
|
||||
window.focus();
|
||||
// reload only here, otherwise the notification will be dismissed
|
||||
|
@ -64,4 +64,4 @@
|
|||
}
|
||||
});
|
||||
}, 60000);
|
||||
}) ();
|
||||
})();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue