'
].join('')
)
if(window.location.pathname.indexOf('share')!= -1){
$('h3').remove();
if($('.center')){
$('.center').append('
')//链接为share按钮位置,此处修改
}}else if(window.location.pathname.indexOf('share')== -1){if($('.topbar-container')){
$('.topbar-container').append('
')//链接为view按钮位置,此处修改
}}
//删除多余元素,或者使其隐藏
if($('.owner-desc-wrap')[0]){
$('.owner-desc-wrap')[0].setAttribute('style','display:none');
}
if($('.header-wrap')[0]){
$('.header-wrap')[0].setAttribute('style','display:none');
}
if($('.aside')[0]){
$('.aside')[0].setAttribute('style','display:none');
}
if($('.fix-searchbar-wrap')[0]){
$('.fix-searchbar-wrap')[0].remove();
}
if($('.top-ads-banner-wrap')[0]){
$('.top-ads-banner-wrap')[0].remove();
}
if($('#activity-tg')[0]){
$('#activity-tg')[0].remove();
}
if($('.crubms-wrap')[0]){
$('.crubms-wrap')[0].setAttribute('style','display:none');
}
if($('.doc-tag-wrap')[0]){
$('.doc-tag-wrap')[0].setAttribute('style','display:none');
}
if($('.doc-value')[0]){
$('.doc-value')[0].setAttribute('style','display:none');
}
if($('.doc-bottom-wrap')[0]){
$('.doc-bottom-wrap')[0].setAttribute('style','display:none');
}
if($('#next_doc_box')[0]){
$('#next_doc_box')[0].setAttribute('style','display:none');
}
if($('.left')[0]){
$('.left')[0].setAttribute('style','display:none');
}
if($('.centerRight')[0]){
$('.centerRight')[0].setAttribute('style','display:none');
}
if($('.ft')[0]){
$('.ft')[0].setAttribute('style','display:none');
}
if($('#ft')[0]){
$('#ft')[0].setAttribute('style','display:none');
}
//使主要内容居中
if($('#doc-main')[0]){
$('#doc-main')[0].setAttribute('style','margin-left:116px');
}
if($('.reader-tools-bar-center')[0]){
$('.reader-tools-bar-center')[0].setAttribute('style','margin-right:0px');
}
var t = null
$('.ez-btn').hover(
function () {
$('.ez-panel')
.css({
top: $('.ez-btn').offset().top - 120 + 'px',
left: $('.ez-btn').offset().left + 70 + 'px'
})
.show()
},
function () {
//链接上经过,保持5秒
$('a').mouseover(
function(){
if (t) window.clearTimeout(t)
t = window.setTimeout(function () {
$('.ez-panel').hide()
},5*1000)
}
)
//移出panel
$('.ez-panel').mouseout(function(){
if (t) window.clearTimeout(t)
t = window.setTimeout(function () {
$('.ez-panel').hide()
},500)
})
//其余情况
if (t) window.clearTimeout(t)
t = window.setTimeout(function () {
$('.ez-panel').hide()
},1000)
}
)
$('.ez-btn').click(function () {
//判断网址是share再打印,否则跳转到share
if(window.location.pathname.indexOf('share')== -1){
window.open('/share/' + window.location.pathname.slice(6),'_blank');//新标签页打开链接,不然window.onload不起作用
}else{
if($('.tools-bar-small')[0]){
$('.tools-bar-small')[0].setAttribute('style','display:none');//点击后隐藏下边栏,防止打印进去
}
prePrint()
}})
$('body').mousedown(function (e) {
if (e.button == 2) {
//imgHandle()
}
return true
})
}
//储存恢复,main
var a = [];
var b = [];
var kong = [];
function saveRecover(){
b = $('[data-render="1"]');
for(var i = 0;i
{
if (
$(item)
.attr('href')
.indexOf('/common_toc/common/style/main') != -1
) {
$(item).remove()
}
})
$('.read-all').click()
$('.header-wrapper').remove()
$('.no-full-screen').remove()
$('.lazy-load').remove()
$('.reader-topbar').remove()
//使打印出来页面居中
$('.main')[0].setAttribute('style','margin-left:-70px')
//重新定义remove方法
jQuery.fn.extend({
remove: function () {
return false
}
})
$(window).scrollTop(0);
window.setTimeout(function () {
saveRecover();
}, 1000)
var _h = document.body.scrollHeight,
_tmp = 700
var _t = window.setInterval(function () {
$(window).scrollTop(_tmp)
saveRecover();
_tmp = _tmp + 700
_h = document.body.scrollHeight
if (_tmp > _h) {
window.clearInterval(_t)
window.setTimeout(function () {
saveRecover();
kong = $("[data-render='']");
for (var i = 0; i < kong.length; i++) {
kong[i].innerHTML = a[i]
}
console.log(kong);
doPrint();
}, 1000)
}
}, 300)
}
/**
* 图片处理,将 div background img 处理成 img 标签,利用 img clip:rect style 来处理图片
* 暂时未找到 img clip:rect 的规律
* //FIXME
*/
function imgHandle() {
$('div.reader-pic-item').each(function (i, item) {
var _style = $(item)[0].style
var _imgUrl = _style.backgroundImage.substring(
5,
_style.backgroundImage.length - 2
)
var imgPanel = '
'
$(item)[0].style.backgroundImage = null
var p = document.createElement('p')
$($(item)[0].attributes).each(function (i, attr) {
$(p).attr(attr.nodeName, attr.nodeValue)
})
$(p).append(imgPanel)
$(item)
.parent()
.html(p)
})
}
/**
* 调用浏览器打印
*/
function doPrint() {
imgHandle()
window.setTimeout(function () {
window.print()
}, 3000)
}
})()