newTable

Reset the car and route number to the table

目前為 2023-05-09 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         newTable
// @namespace    https://www.conanluo.com/
// @version      1.36.5
// @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
        //update .da style
        for(let obj of document.getElementsByClassName("da") ){
            obj.style['box-shadow']="";//clear shado box
            obj.style['border-right']="0px";
            obj.style['border-left']="0px";
        }

        //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("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);