Answer the question
In order to leave comments, you need to log in
How to make one script execute synchronously in different browser tabs?
To work, I need a script-timer that works on VK pages, which would be updated every time a certain key combination is pressed. Did business in tampermanki.
1) I created the timer itself:
2) Added two functions to make it work and update:<p id="data-time"> 360 </p>
function timerito() {
var elem=document.getElementById('data-time');
if(elem.innerHTML!=0) {
elem.innerHTML--;
setTimeout(timerito, 1000);
}
else alert('Пора делать SMM!');
}
function timerback() {
var elem=document.getElementById('data-time');
if(elem.innerHTML!=360) {
elem.innerHTML=360;
}
}
var altIsPressed = false;
$(window).keydown(function(event){
if(event.keyCode == 18) {
altIsPressed = true; event.preventDefault();
}
});
window.onkeydown = function(event) {
if (altIsPressed && event.keyCode === 67) {
event.preventDefault(); timerback();
}
}
setTimeout(timerito, 1000);
Answer the question
In order to leave comments, you need to log in
With a chrome extension, there shouldn't be any problems at all.
You insert the Content script only on VK pages (well, or on everything if you need it) . You
use the background page as a signaling mechanism for synchronizing timers.
In general, you can use the timer only on the background page, and through the content script, insert a display on the page.
In the Documentation , everything is described in detail
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question