var st=1;

var wai=1;

var Pz=1;

var UpdatePade=1;

var waiUpdatePade=1;

var NUpdatePade;

var element, elements, index, strE, nS;

var Alls;

var var_input;

var Run_button;

var Refresh_button;

SUpdatePade();

Num();

Paus();

WPaus();

CreateButton();

var T_OBN=0;

if (document.readyState != "complete")T_OBN=1;

var T=0;

var T_Pz=Date.now();

setInterval(function() {

setTimeout (Tim, 100);

},100);

function Tim(){

if (T==0) {

setTimeout (Run, 100);

}}

function Run()

 { 

if (T==1) return;

T=1;

if (Date.now()<T_Pz+Pz){T=0; return;}

if (UpdatePade==2){if (T_OBN==1){if (document.readyState == "complete"){UpdatePade=1; waiUpdatePade=1; addUpdatePade(); T=0; return;}}}

if (UpdatePade==2) {

if (waiUpdatePade-Date.now()<0){st=NUpdatePade; addNum(); UpdatePade=1; waiUpdatePade=1; addUpdatePade(); T_Pz=Date.now(); Pz=1; addPz(); wai=Date.now(); addWai(); T=0; All_Call_Send(); return;} T=0; return;}

st=1; wai=1; T_Pz=Date.now(); Pz=1; UpdatePade=1; waiUpdatePade=1;

addNum(); addUpdatePade(); addPz(); addWai(); All_Call_Send();

}

//EndRun()

function Stop()

{

chrome.runtime.sendMessage({greeting: "bye"}, function(response) {

console.log(response.farewell);});

st=500;

addNum();

Run_button.innerHTML = "Отключено";

Refresh_button.innerHTML = "--";

var_input.value = "Отключено";

throw new Error('Stop');

}

function Refresh()

{

chrome.runtime.sendMessage({greeting: "reflesh"}, function(response) {

console.log(response.farewell);});

location.reload();

}

function addNum()

{

chrome.runtime.sendMessage({NM: st}, function(response) {

var tst=response.farewell;});

}

function Num()

{

chrome.runtime.sendMessage({greeting: "var_num"}, function(response) {

st=response.farewell;});

}

function SUpdatePade()

{

chrome.runtime.sendMessage({greeting: "var_UP"}, function(response) {

UpdatePade=response.farewell;});

chrome.runtime.sendMessage({greeting: "var_UP1"}, function(response) {

waiUpdatePade=response.farewell;});

chrome.runtime.sendMessage({greeting: "var_UP2"}, function(response) {

NUpdatePade=response.farewell;});

}

function addUpdatePade()

{

chrome.runtime.sendMessage({UP: UpdatePade}, function(response) {

var tst=response.farewell;});

chrome.runtime.sendMessage({UP1: waiUpdatePade}, function(response) {

var tst=response.farewell;});

chrome.runtime.sendMessage({UP2: NUpdatePade}, function(response) {

var tst=response.farewell;});

}

function addPz()

{

chrome.runtime.sendMessage({Paze: Pz}, function(response) {

var tst=response.farewell;});

}

function Paus()

{

chrome.runtime.sendMessage({greeting: "var_Pz"}, function(response) {

Pz=response.farewell;});

}

function addWai()

{

chrome.runtime.sendMessage({Wi: wai}, function(response) {

var tst=response.farewell;});

}

function WPaus()

{

chrome.runtime.sendMessage({greeting: "var_Wai"}, function(response) {

wai=response.farewell;});

}

function Pause()

{

alert("Пауза");

}

function Copy()

{

let html = new XMLSerializer().serializeToString(document);


navigator.clipboard.writeText(html);

}

function CreateButton()

{

Refresh_button = document.createElement("Button");

Refresh_button.innerHTML = "Обновить";

Refresh_button.className = "RefreshClassName";

Refresh_button.style = "top:0px; left:0px; position:fixed; z-index: 999999; background-color:gray; color:white; font-size:16px";

Refresh_button.onclick = function(){ Refresh();};

document.body.appendChild(Refresh_button);

Run_button = document.createElement("Button");

Run_button.innerHTML = "Отключить";

Run_button.className = "RunButtonClassName";

Run_button.style = "top:0px; right:0px; position:fixed; z-index: 999999; background-color:gray; color:white; font-size:16px";

Run_button.onclick = function(){ Stop();};

document.body.appendChild(Run_button);

var Pause_button = document.createElement("Button");

Pause_button.innerHTML = "Пауза";

Pause_button.className = "PauseButtonClassName";

Pause_button.style = "top:30px; right:0px; position:fixed; z-index: 999999; background-color:gray; color:white; font-size:16px";

Pause_button.onclick = function(){ Pause();};

document.body.appendChild(Pause_button);

var Copy_button = document.createElement("Button");

Copy_button.innerHTML = "Копировать";

Copy_button.className = "CopyButtonClassName";

Copy_button.style = "top:60px; right:0px; position:fixed; z-index: 999999; background-color:gray; color:white; font-size:16px";

Copy_button.onclick = function(){ Copy();};

document.body.appendChild(Copy_button);

var_input = document.createElement("input");

var_input.type = "text";

var_input.className = "VarInputclassName";

var_input.style = "top:30px; left:0px; position:fixed; z-index: 999999; background-color:white; color:gray; font-size:16px";

document.body.appendChild(var_input);

}



function All_Call_Send()

{

}