刪完垃圾代碼2

來源:互聯網
上載者:User

標籤:style   blog   http   color   io   os   ar   for   div   

content_script.js

 

// window.addEventListener("load", function() {//     chrome.extension.sendMessage({//         type: "dom-loaded", //         data: {//             myProperty: "this is so cool!!!----One-Time Requests,communication happens only once"//         }//     });// }, true);//=======================this is for the hover=======================(function(window){var document = window.document,    body = document.body,    a = document.getElementsByTagName(‘a‘),  //for get a href,returns a live HTMLCollection of elements with the given tag name    currentLength = a.length,    currentLinks = [],    displayTimeout,    normalURL,    zIndex=100,    container,    // containerLabel,    button,    size = 1.0,    rate,    on,    showModel,    hovernow,  //to judge whether the mouse point is on hovering    delayTime;loadSettings();addEvents();drawWindow();//從storage中獲得值,進行初始化工作function loadSettings(){    chrome.storage.sync.get([        ‘hoverLinkPosition‘,        ‘hoverLinkOffsetX‘,        ‘hoverLinkOffsetY‘,        ‘hoverLinkNormal‘,        ‘hoverLinkDelayTime‘,        ‘hoverLinkRate‘,        ‘on‘,        ‘model‘],         function(data){         rate = data.hoverLinkRate;             moveBox(data.hoverLinkPosition, data.hoverLinkOffsetX, data.hoverLinkOffsetY);         normalURL = data.hoverLinkNormal;         delayTime = data.hoverLinkDelayTime;         on = data.on;         showModel = data.model;         // console.log("log in content"+on);    });}function moveBox(s,x,y){    // var str = "Hello world!"; //      var res = str.substr(1, 4)    var a = s.substring(0,s.indexOf(‘-‘)),        b = s.substr(s.indexOf(‘-‘)+1);  // ??        // console.log(a); //top        // console.log(b);  //right       // container.setAttribute(‘style‘,‘z-index:‘+zIndex+‘;‘);        container.style[a]=y+‘px‘;  //style裡面存放json ,所以a,b是key        container.style[b]=x+‘px‘;        container.style[‘overflow‘]=‘scroll‘;        container.style[‘max-width‘]=‘1450px‘;        container.style[‘max-height‘]=‘400px‘;        container.style[‘-webkit-transform‘] = ‘scale(‘+rate+‘)‘;        container.style[‘-webkit-transform-origin‘] = ‘0px 0px‘;        //"-webkit-transform: scale(0.43);-webkit-transform-origin: 200px 100px;overflow:scroll"}function addEvents(){    for(var i=currentLength-1;i>=0;i--){        addEvent(a[i]);        currentLinks.push(a[i]); //放入數組中    }}function addEvent(a){    a.addEventListener(‘mouseover‘,linkMouseOver,false);//當mouseover觸發,調用linkMouseOver    a.addEventListener(‘mouseleave‘,linkMouseOut,false);    $(‘body‘).on(‘click‘,mouseclick);}function linkMouseOver(event){    var url = this.href;  //this應該指a標籤    //console.log("client :top->"+event.clientY+" left->"+event.clientX +" offset:top->"+window.pageYOffset+" left->"+window.pageXOffset);    container.style[‘top‘] = event.clientY+‘px‘    container.style[‘left‘] = event.clientX+‘px‘;    hovernow = 1;    displayTimeout = setTimeout(function(){         displayBox();         setTimeout(function(){           mouseOver(url);         },1500);         //mouseOver(url);    },delayTime)}function linkMouseOut(event){    console.log(‘now mouseout‘);    hovernow = 0;    clearTimeout(displayTimeout); //Prevent the function set with the setTimeout() to execute    if(!container){    //$("body").removeChild(container);    body.removeChild(container);    }else{        container.style.display= ‘none‘;    }     }function mouseOver(url){    if(hovernow==1){        console.log(‘now mouseover‘);        $.post(‘http://gozoom4235.appspot.com/highlight.php‘,{url:url},function(webdata){        //displayBox();        if(showModel==1){               insertLabel(webdata);        }else{             showWord(webdata);        }        })    }}function mouseclick(event){    clearTimeout(displayTimeout);    if(!container){    //$("body").removeChild(container);    body.removeChild(container);    }else{        container.style.display= ‘none‘;    }}function displayBox() {    container.innerHTML = "loading.....";    if(on==1){    body.appendChild(container);//appendChild會把之前所有關於container的以html節點方式加入,到這裡才會在html中顯示    $(container).show(‘fast‘);    }}function requestURL(link){    sendMessage({        hoverLink:‘findURL‘,        url:link    });   //jason}function sendMessage(message){    //chrome.runtime.sendMessage(message,empty);}function empty(){}//========unknowfunction drawWindow() {    //畫一個框子顯示usrl        var all = document.getElementsByTagName(‘*‘);        for ( var i=all.length; i >= 0; i-- ) {            var style = getComputedStyle(all[i]);            if ( !style )                continue;            var z = parseInt(style.getPropertyValue(‘z-index‘));            if ( z > zIndex )                zIndex = z+1;        }        var _container = document.createElement(‘div‘);          _container.id = ‘hoverLinkContainer‘;        _container.style.zIndex = zIndex;        container = _container;    }// function showFinalURL(url){//    insertLabel(url);// }    function insertLabel(txt){    //txt=txt.substring(1,txt.length-1);    container.innerHTML=txt;    //嵌入到文本中(注意是‘’不是“”)    //container.innerHTML=‘<button onclick="zoomout()">enlarger</button><input type="button" id ="button2" value="smaller" onclick="zoomin()"><div>‘+txt+‘</div>‘;}function showWord(webdata){     $.post(‘http://gozoom4235.appspot.com/body.php‘,{webdata:webdata},function(data){ //http://localhost/body.php         console.log(data);     insertLabel(data);});    }})(window);

 

刪完垃圾代碼2

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.