Skip to content

Commit

Permalink
增加@config,修正卡饭论坛新标签页打开问题,更改 noLzayImage 为另一个方式
Browse files Browse the repository at this point in the history
  • Loading branch information
ywzhaiqi committed Oct 13, 2014
1 parent 2baa3e8 commit e177e78
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions uAutoPagerize2/uAutoPagerize2.uc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
// @modified ywzhaiqi
// @compatibility Firefox 17
// @charset UTF-8
// @version 2014.9.8
// @version 2014.10.13
// version 0.3.0
// @inspect window.uAutoPagerize
// @startup window.uAutoPagerize.init();
// @shutdown window.uAutoPagerize.destroy();
// @config window.uAutoPagerize.edit(uAutoPagerize.file_CN, null, true);uAutoPagerize.edit(uAutoPagerize.file);
// @homepageURL https://github.com/ywzhaiqi/userChromeJS/tree/master/uAutoPagerize2
// @downloadURL https://github.com/ywzhaiqi/userChromeJS/raw/master/uAutoPagerize2/uAutoPagerize2.uc.js
// @reviewURL http://bbs.kafan.cn/thread-1555846-1-1.html
Expand Down Expand Up @@ -883,6 +885,9 @@ var ns = window.uAutoPagerize = {
var arr = Array.slice(df.querySelectorAll('a[href]:not([href^="mailto:"]):not([href^="javascript:"]):not([href^="#"])'));
arr.forEach(function (elem){
elem.setAttribute('target', '_blank');
if (elem.getAttribute('onclick') == 'atarget(this)') { // 卡饭论坛的控制是否在新标签页打开
elem.removeAttribute('onclick');
}
});
});

Expand Down Expand Up @@ -1868,17 +1873,21 @@ AutoPager.prototype = {
// 修正延迟加载的图片
var lazyImgSrc = (this.info.lazyImgSrc === undefined) ? prefs.lazyImgSrc : this.info.lazyImgSrc;
if (lazyImgSrc) {
var imgAttrs = lazyImgSrc.split('|');
imgAttrs.forEach(function(attr){
attr = attr.trim();
[].forEach.call(fragment.querySelectorAll("img[" + attr + "]"), function(img){
var newSrc = img.getAttribute(attr);
if (newSrc && newSrc != img.src) {
img.setAttribute("src", newSrc);
img.removeAttribute(attr);
var lazyAttributes = lazyImgSrc.split('|');

var noLazyNode = function (node) {
lazyAttributes.some(function(attr) {
if (!node.hasAttribute(attr)) return;

var newSrc = node.getAttribute(attr);
if (node.src != newSrc) {
node.src = newSrc;
}
return true;
});
});
};

[].map.call(fragment.querySelectorAll('img'), noLazyNode);
}

//收集所有图片
Expand Down Expand Up @@ -2982,4 +2991,4 @@ function saveFile(fileOrName, data) {
\
'.replace(/\n|\t/g, ''));

window.uAutoPagerize.init();
window.uAutoPagerize.init();

0 comments on commit e177e78

Please sign in to comment.