Skip to content

Instantly share code, notes, and snippets.

@alexpts
Created January 31, 2020 10:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexpts/664d5b551c68393a55be2eb90239bb38 to your computer and use it in GitHub Desktop.
Save alexpts/664d5b551c68393a55be2eb90239bb38 to your computer and use it in GitHub Desktop.
tampermonkey Auto click optmize map.js
// ==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