Skip to content

Instantly share code, notes, and snippets.

@mhz-tamb
Created July 7, 2017 17:33
Show Gist options
  • Save mhz-tamb/f0319dac5b9219f8c4b9e7d11c0dc4a7 to your computer and use it in GitHub Desktop.
Save mhz-tamb/f0319dac5b9219f8c4b9e7d11c0dc4a7 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name BattleGroup
// @namespace DreamWar
// @version 0.1
// @description try to take over the world!
// @author Sergey Shiryaev <sergey@shiryaev.pro>
// @match http://dreamwar.ru/battle_group.php*
// @run-at document-end
// @grant none
// ==/UserScript==
Notification.requestPermission();
(() => {
'use strict';
let refresh = document.querySelector('[accesskey="5"]');
let submit = document.querySelector('input[type="submit"]');
let sleep = (time) => {
return new Promise((resolve) => setTimeout(resolve, time));
};
if (Notification.permission === "granted" && !submit && !refresh) {
let notification= new Notification('Бой завершен');
setTimeout(() => {
notification.close();
}, 2500);
}
sleep(250).then(() => {
Array.prototype.forEach.call(document.querySelectorAll('input[name="skills[]"]'), (item) => {
item.setAttribute('checked', true);
});
if (submit !== null) submit.click(); else refresh.click();
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment