Check the connection

Check the connection, A tool to check your Internet connection

目前為 2017-10-22 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Check the connection
// @namespace    https://www.waze.com/*
// @version      0.4
// @description  Check the connection, A tool to check your Internet connection
// @author       sultan alrefaei
// @match        https://www.waze.com/editor/
// @match        https://www.waze.com/ar/editor/
// @match         https://www.waze.com/editor
// @match        https://www.waze.com/ar/editor
// @grant        none
// @copyright    2017 sultan alrefaei
// ==/UserScript==


var saveNow = 25; // عدد مرات التعديل المسموح بها 25، يمكنك تغيرها الى العدد الذي تريد


window.onload = function(e){
    var isCon = true;
    setInterval(function(){ 
        if (document.getElementsByClassName("toolbar-button waze-icon-save ItemInactive")[0] != undefined){
            if (document.getElementsByClassName("toolbar-button waze-icon-save ItemInactive")[0] != null){
                document.getElementsByClassName("toolbar-button waze-icon-save ItemInactive")[0].setAttribute("id","SaveBTN");
            }   
        }
        if (document.getElementsByClassName("toolbar-button waze-icon-save ItemInactive")[0] != null){
            document.getElementById("SaveBTN").addEventListener("click",function(){
                if (document.getElementById("connected") != null){
                    document.getElementById("connected").remove();
                }
            });
        }
        var c = document.getElementsByClassName("counter");
        var counter = parseInt(c[0].innerText);
        if (counter >= saveNow && isCon){
            createAlert();
            isCon = false;
        }
        if (counter == 0){
            isCon = true;
            if (document.getElementById("connected") != null){
                document.getElementById("connected").remove();
            }
        }
    },100);
}

function createAlert(){
    var URLLANG = window.location.href;
    if (URLLANG.includes("ar") == true){
        if (document.getElementById("connected") == null){
            var div = document.createElement("div");
            div.id = "connected";
            div.style.position = "absolute";
            div.style.zIndex = 10000;
            div.style.top = "35px";
            div.style.width = "150px";
            div.style.height = "30px";
            div.style.fontSize = "20px";
            div.title = "إغلاق التنبيه";
            div.style.borderRadius = "7px";
            div.style.cursor = "pointer";
            div.onclick = function(){
                div.remove();
            }
            div.style.right = "45%";
            div.style.backgroundColor = "white";
            div.style.boxShadow = "1px 1px #ab3232";
            div.innerHTML = "<div align='center'>قم بحفظ التعديلات</div";
            document.getElementById("WazeMap").appendChild(div);
            try{
                requestServer("https://www.waze.com/");
            }
            catch(err) {
                if (div != null){
                    div.innerHTML = "<div align='center'>لا يوجد إتصال</div";
                }  
            } 
        }
    }else{
        if (document.getElementById("connected") == null){
            var div = document.createElement("div");
            div.id = "connected";
            div.style.position = "absolute";
            div.style.zIndex = 10000;
            div.style.top = "35px";
            div.style.width = "150px";
            div.style.height = "30px";
            div.style.fontSize = "20px";
            div.title = "Close";
            div.style.borderRadius = "7px";
            div.style.cursor = "pointer";
            div.onclick = function(){
                div.remove();
            }
            div.style.right = "45%";
            div.style.backgroundColor = "white";
            div.style.boxShadow = "1px 1px #ab3232";
            div.innerHTML = "<div align='center'>Save your edits</div";
            document.getElementById("WazeMap").appendChild(div);
            try{
                requestServer("https://www.waze.com/");
            }
            catch(err) {
                if (div !== null){
                    div.innerHTML = "<div align='center'>No connection</div";
                }  
            } 
        }
    }
    
}

function requestServer(URL){
    var getReguest = new XMLHttpRequest();
    getReguest.open("GET",URL,false);
    getReguest.send(null);
}

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址