百度百科 无水印图片查看

查看百科最新版本、历史版本无水印图片,历史图册页面进入的图片暂时不支持。

目前為 2016-03-12 提交的版本,檢視 最新版本

// ==UserScript==
// @icon           http://baidu.com/favicon.ico
// @name           百度百科 无水印图片查看
// @namespace      http://weibo.com/liangxiafengge
// @version        1.2.1
// @description    查看百科最新版本、历史版本无水印图片,历史图册页面进入的图片暂时不支持。
// @match          http://baike.baidu.com/picture/*
// @match          http://baike.baidu.com/historypic/*
// @match          http://baike.baidu.com/pic/*
// @match          http://baike.baidu.com/picview/history/*
// @run-at         document-end
// ==/UserScript==

var imgFrameId   = 'imgPicture';                               //图片所在元素的id
var imgURLnum    = 6;                                          //无水印图片url的网址长度(以/字符分割)
var clearImgHost = 'imgsrc.baidu.com';                         //无水印图片的host
var prevPicLink  = document.getElementById( imgFrameId ).src;  //用于对比,图片链接是否变化
var isFirst      = 1;
//获取元素
var imgPicture   = document.getElementById( imgFrameId );
var imgId        = imgPicture.src.split('/')[imgURLnum];
var imgButton    = document.getElementsByClassName('tool-button origin')[0];
document.getElementsByClassName('tool-button info')[0].style.display = 'none';

var check        = setInterval( changeImg , 100 );             //定时执行,以替换掉

// 按下左键,重新替换
document.onmouseup= leftButton;
function leftButton(e){
    var e=window.event||e;//获取事件对象
    var value=e.button;
    // 0 left ; 1 middle; 2 right
    (value===0)   ||  ( setTimeout( reGet, 100) );
}
// 鼠标滚动,重新替换
window.onmousewheel=document.onmousewheel=scrollFunc;
function scrollFunc(){
   setTimeout( reGet, 200);
}
//按动了上下方向键,38=上键,37=左键,40=下键,39=右键
document.onkeydown=function(event){
    var e = event || window.event || arguments.callee.caller.arguments[0];
    if(e && e.keyCode==38 || e && e.keyCode==39){//上,下
        setTimeout( reGet, 100);
    }
};
// 重新获取图片信息
function reGet(){
    ( imgPicture = document.getElementById( imgFrameId ) )  &&  ( imgButton=document.getElementsByClassName('tool-button origin')[0]  )  &&  ( check=setInterval( changeImg , 100) ) ;
}
//替换有水印的图片,替换“原图”中的链接
function changeImg()
{
    if (  (imgPicture.src != prevPicLink ) || ( isFirst === 1 )  )
    {
        imgId= imgPicture.src.split('/')[imgURLnum] ;
        imgButton.href = imgPicture.src = 'http://imgsrc.baidu.com/baike/pic/item/' + imgId;
        imgButton.innerHTML = '原图:' + document.getElementsByClassName('size')[0].innerHTML;
        prevPicLink=imgPicture.src;
        check=window.clearInterval( check );
        isFirst = 0;
    }
} 

QingJ © 2025

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