Chrome 简单插件开发

View Code
<?xml version="1.0" encoding="utf-8"?>
<extension>
    <id>com.sogou.PageTurn</id>
    <name>翻页跳转</name>
    <show_icon>true</show_icon>
    <description>返回顶部,点击翻页,返回顶部,快捷操作</description>
    <version>0.0.0.1</version>
    <request_api_version>1</request_api_version>
    <show_menu_dropdown>true</show_menu_dropdown>
    <author>lvxiaojia</author>
    <background page="background.html" />    
    <content_scripts>
        <content_script>
            <match>*://*/*</match>
            <js>jquery-1.4.1.min.js</js> 
            <js>top.js</js> 
        </content_script>
    </content_scripts>
</extension>

 

View Code
.sougougo{width:47px;height:108px;background:#FFF;position:fixed;filter:alpha(opacity=60);   
      -moz-opacity:0.6;z-index:900000; -khtml-opacity: 0.6; opacity: 0.6;_position:absolute;right:12px;_right:-47px;bottom:2%;border-radius:2px;box-shadow:0 0 2px #6E6E6E;display:none;}
.sougougo a{background:url('images/a.png') no-repeat;display:block;width:37px;margin:5px;border:0;overflow:hidden;float:left}
.sougougo .sougoutop{background-position:0 -33px;height:22px}
.sougougo .sougoucenter{background-position:0 -54px;height:32px}
.sougougo .sougoubottom{background-position:0 -88px;height:22px}
.sougougo .sougoutop:hover{background-position:-38px -33px}
.sougougo .sougoucenter:hover{background-position:-38px -54px}
.sougougo .sougoubottom:hover{background-position:-38px -88px}

 

View Code js
changeUi();
function changeUi(){
 var imgpatch = sogouExplorer.extension.getURL('images/a.png');
    var style = document.createElement("link");
    style.href = sogouExplorer.extension.getURL('style.css');
    style.rel = "stylesheet";
    style.type = "text/css";    
    document.getElementsByTagName("head").item(0).appendChild(style);    
    var scriptelement=document.createElement("script");
    scriptelement.type="text/javascript";
    if(typeof(jQuery)=="undefined"){
        alert('jquery bucunzai');
        var jquerypatch = sogouExplorer.extension.getURL('jquery-1.4.1.min.js');
            scriptelement.src=jquerypatch;
        document.getElementsByTagName("head").item(0).appendChild(scriptelement);    
    }    
    
    var ht=document.createElement("div");
    ht.innerHTML="<div class='sougougo'><a class='sougoutop' title='返回顶部'/><a class='sougoucenter' title='自动翻页'/><a class='sougoubottom' title='返回底部'/></div>";
        
    document.getElementsByTagName("body").item(0).appendChild(ht);
    
    $(".sougoutop").click(function(){
        $("html, body").animate({scrollTop: 0},220);
    });
    $(".sougoubottom").bind("click",function(){            
            $("html, body").animate({scrollTop: $(document).height()},220);
        });
    
    $(".sougoucenter").click(function(){
        var d = $(document).scrollTop()+$(window).height();
        $("html, body").animate({scrollTop: d},220);
    });
    $(window).bind("scroll",function(){
            var d = $(document).scrollTop(),
            e = $(window).height();            
            d>1?$(".sougougo").show("slow") : $(".sougougo").hide("slow");
        });
        
}

 

      下载

转载于:https://www.cnblogs.com/lvxiaojia/archive/2013/02/22/2889624.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值