Created
January 31, 2020 10:21
-
-
Save alexpts/664d5b551c68393a55be2eb90239bb38 to your computer and use it in GitHub Desktop.
tampermonkey Auto click optmize map.js
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
// ==UserScript== | |
// @name Auto click optmize map | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author You | |
// @match https://yandex.ru/maps/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
let buttonOptimize = false; | |
let intervalId = setInterval(() => { | |
buttonOptimize = document.querySelector('.route-common-settings-form-view__optimize'); | |
if (buttonOptimize === null) { | |
console.log('Кнопка оптимизировать не найдена в DOM'); | |
return; | |
} | |
// window.addEventListener('popstate' не работает соыбтие почему-то | |
let currentUrl = window.location.href; | |
buttonOptimize.click(); | |
clearInterval(intervalId); | |
intervalId = setInterval(() => { | |
if (currentUrl !== window.location.href) { | |
console.log(currentUrl); | |
console.log(window.location.href); | |
clearInterval(intervalId); | |
} | |
}, 1000); | |
}, 1000); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment