newTable

Reset the car and route number to the table

ของเมื่อวันที่ 04-05-2023 ดู เวอร์ชันล่าสุด

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey, Greasemonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

You will need to install an extension such as Tampermonkey to install this script.

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         newTable
// @namespace    https://www.conanluo.com/
// @version      1.36.2
// @description  Reset the car and route number to the table
// @author       Conan
// @match        *://*.itinerisonline.com/*
// ==/UserScript==



(function(window) {// testing
    'use strict';

    function getC(str){
        return document.getElementsByClassName(str)
    }
    function getId(str){
        return document.getElementByID(str)
    }

    function resetRoute(){

        function ca04Replace(dom,routeNumber){//replace "CA04" to be route number
            dom.innerHTML=dom.innerHTML.replace( "CA04" , "  <strong style='font-size:20px;color:DarkMagenta'>"+routeNumber+"</br></strong> ")

        }
        function nameReplace(dom,oName,nName){//replace driver name
            dom.innerHTML=dom.innerHTML.replace(oName,`<font color="6495ED" style="font-size:17px;background:lightgrey">${nName}</font>`)
        }

        function replacing(dom){
            let changer=[
                    [(dom.innerHTML.indexOf( "IOA-14" )!=-1 && dom.innerHTML.indexOf( "Li" )==-1)||dom.innerHTML.indexOf( "IOA-21" )!=-1,
                    "Route 1",
                    ["Fung","Ken"]],
                    [dom.innerHTML.indexOf("IOA-15" )!=-1,
                    "Route 2",
                    ["Reina","Mauricio"]],
                    [dom.innerHTML.indexOf( "IOA-19" )!=-1,
                    "Route 4",
                    ["Alejandro","Jerald"]],
                    [dom.innerHTML.indexOf( "IOA-22" )!=-1,
                    "Route 5",
                    ["Santos","Ulises"]],
                    [dom.innerHTML.indexOf( "IOA-20" )!=-1 || dom.innerHTML.indexOf( "V-273" )!=-1,
                    "Route 6",
                    ["Mejia","Walter"]],
                    [dom.innerHTML.indexOf( "IOA-17" )!=-1,
                    "Route 8",
                    ["Reina","Manuel"]],
                    [dom.innerHTML.indexOf( "IOA-16" )!=-1,
                    "Route 9",
                    ["Chen","Raymond"]],
                    [dom.innerHTML.indexOf( "IOA-11" )!=-1,
                    "Route 10",
                    ["Reid","Bert"]],
                    [dom.innerHTML.indexOf( "V-366" )!=-1 || dom.innerHTML.indexOf( "V-310" )!=-1 || dom.innerHTML.indexOf("V-324")!=-1,
                    "Mini Van",
                    ["Zhou","Joe"]],
                    [dom.innerHTML.indexOf( "IOA-12" )!=-1 || (dom.innerHTML.indexOf( "IOA-14" )!=-1 && dom.innerHTML.indexOf( "Li" )!=-1 ),
                    "Kang",
                    ["Li","Li"]]
                ];

            for(let i=0;i<changer.length;i++){
                if(changer[i][0]){
                    ca04Replace(dom,changer[i][1]);
                    nameReplace(dom,changer[i][2][0],changer[i][2][1]);
                }
            }
        }

        for(let i=0;i<getC("vehicle-and-driver").length;i++){
            let dom=getC("vehicle-and-driver")[i]
            replacing(dom);

        }

    }

    function continuedReset(){ // all function will run frequently
        resetRoute();
    }

    setInterval(continuedReset, 1000);//every 1 seconed run all function in continuedReset()


    function resetAllIWant(){

        //set default
        document.getElementsByClassName("checkpoints-map")[0].style.display="none";//hide the map
        document.getElementsByClassName("well")[0].classList.add("offscreen");//hide the "well" div
        document.getElementsByClassName("scrollable-90")[1].classList.remove("scrollable-90");//remove the scroll bar
        document.getElementsByClassName("scrollable-90")[0].classList.remove("scrollable-90");//remove the scroll bar

        //add btn place
        let addPlace=document.getElementsByTagName("h4")[0];

        //btns
        let cutBtnDom=`<button class="btn btn-success" onclick='let table=document.getElementsByClassName("table-condensed")[0];
        for(let i=3;i<table.rows.length;i=i+2){
            if(table.rows[i].cells[1].innerHTML!="  "){
                table.rows[i].style.display="none";
                try{
                    table.rows[i+1].style.display="none";
                }catch(e){}
            }
            if(table.rows[i].innerHTML.indexOf("Lunch")!=-1){
                table.rows[i].style.display="none";
            }
        };console.log("Short");'>Short table</button>

        <button class="btn btn-success" onclick='let table=document.getElementsByClassName("table-condensed")[0];
        for(let i=3;i<table.rows.length;i=i+2){
            table.rows[i].style.display="none";
            try{
                table.rows[i+1].style.display="none";
            }catch(e){}
        };console.log("cut");'>Cut table</button>

        <button class="btn btn-success" onclick='let map=document.getElementsByClassName("checkpoints-map")[0];
        if(map.style.display=="none"){
            map.style.display="block";
            this.innerText="Show Map";
        }else{
            map.style.display="none";
            this.innerText="Hide Map";
        }
        console.log(this.innerText);'>Show map</button>`;

        //Global keydown listener
        window.isKeyOn=false;
        window.addEventListener("keydown",function(event){
            //event.preventDefault();
            if(event.keyCode==124){//switch to Global or
                window.isKeyOn=!window.isKeyOn;
            }

            if(window.isKeyOn){
                let serchBox=document.getElementsByName("quickFilterForm")[0].getElementsByTagName("input")[0];
                serchBox.focus();
            }
        });
        addPlace.innerHTML=addPlace.innerHTML+cutBtnDom;

    }
    setTimeout(resetAllIWant, 1000);
})(window);