Skip to content

Commit

Permalink
6.4.4 增加黑名单设置
Browse files Browse the repository at this point in the history
  • Loading branch information
ywzhaiqi committed Sep 17, 2014
1 parent f7f44d9 commit 08aa782
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 36 deletions.
2 changes: 1 addition & 1 deletion Super_preloaderPlus/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "super_preloaderplus_one",
"version": "6.4.4",
"version": "6.4.5",
"devDependencies": {
"grunt": "~0.4.5",
"grunt-contrib-clean": "~0.5.0",
Expand Down
24 changes: 16 additions & 8 deletions Super_preloaderPlus/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ var setup = function(){
#sp-prefs-setup input, #sp-prefs-setup select { border:1px solid gray;padding:2px;background:white; }\
#sp-prefs-setup li { margin:0;padding:6px 0;vertical-align:middle;background:#eee;border:0 }\
#sp-prefs-setup button { width:150px;margin:0 10px;text-align:center; }\
#sp-prefs-custom_siteinfo { width:98%;height:100px;margin:3px 0; }\
#sp-prefs-setup textarea { width:98%; height:60px; margin:3px 0; }\
#sp-prefs-setup b { font-weight: bold; font-family: "微软雅黑", sans-serif; }\
');

var div = d.createElement('div');
Expand All @@ -113,6 +114,9 @@ var setup = function(){
<li><input type="checkbox" id="sp-prefs-SITEINFO_D-useiframe" /> 在预读模式下,默认启用 iframe 方式</li>\
<li><input type="checkbox" id="sp-prefs-SITEINFO_D-a_enable" /> 默认启用自动翻页 </li>\
<li><input type="checkbox" id="sp-prefs-SITEINFO_D-a_force_enable" /> 自动翻页默认启用强制拼接</li>\
<li>自定义排除列表:\
<div><textarea id="sp-prefs-excludes" placeholder="自定义排除列表,支持通配符。\n例如:http://*.douban.com/*"></textarea></div>\
</li>\
<li>自定义站点规则:\
<div><textarea id="sp-prefs-custom_siteinfo" placeholder="自定义站点规则"></textarea></div>\
</li>\
Expand All @@ -138,23 +142,28 @@ var setup = function(){
debug = xbug ? console.log.bind(console) : function() {};

GM_setValue('dblclick_pause', $('dblclick_pause').checked);

GM_setValue('excludes', prefs.excludes = $('excludes').value);
GM_setValue('custom_siteinfo', prefs.custom_siteinfo = $('custom_siteinfo').value);

SP.loadSetting();

close();
});

on($('cancel'), 'click', close);

$('checkUpdate').onclick = checkUpdate();
$('checkUpdate').onclick = checkUpdate;
$('debug').checked = xbug;
$('enableHistory').checked = prefs.enableHistory;
$('dblclick_pause').checked = GM_getValue('dblclick_pause') || false;
$('SITEINFO_D-useiframe').checked = SITEINFO_D.useiframe;
$('SITEINFO_D-a_enable').checked = SITEINFO_D.autopager.enable;
$('SITEINFO_D-a_force_enable').checked = SITEINFO_D.autopager.force_enable;
$('excludes').value = prefs.excludes;
$('custom_siteinfo').value = prefs.custom_siteinfo;

// 打开设置自动检查更新
checkUpdate();
};

function checkUpdate() {
Expand Down Expand Up @@ -1663,11 +1672,10 @@ function init(window, document) {

//执行开始..///////////////////

//分析黑名单
var item = _.find(blackList, function(x){ return x[1] && toRE(x[2]).test(url); });
if(item){
debug('匹配黑名单', item, 'js执行终止');
debug('全部过程耗时', new Date() - startTime, '毫秒');
// 分析黑名单
var blackList_re = new RegExp(blackList.map(wildcardToRegExpStr).join("|"));
if(blackList_re.test(url)){
debug('匹配黑名单,js执行终止');
return;
}

Expand Down
18 changes: 10 additions & 8 deletions Super_preloaderPlus/src/rule.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,22 @@ var prefs={
debug: GM_getValue('debug', false),
enableHistory: GM_getValue('enableHistory', false), // 把下一页链接添加到历史记录
autoGetPreLink: false, // 一开始不自动查找上一页链接,改为调用时再查找
custom_siteinfo: GM_getValue('custom_siteinfo') || '[]',
excludes: GM_getValue('excludes', ''),
custom_siteinfo: GM_getValue('custom_siteinfo', '[]'),
lazyImgSrc: 'zoomfile|file|original|load-src|_src|imgsrc|real_src|src2|data-lazyload-src|data-ks-lazyload|data-lazyload|data-src|data-original|data-thumb|data-imageurl|data-defer-src|data-placeholder',
};

//黑名单,网站正则..
// 黑名单,网站正则..
var blackList=[
// ['中关村首页',false,/^http:\/\/www\.zol\.com\.cn\/(?:#.*)?$/i],
// ['Gmail', true, /mail\.google\.com/i],
// ['Google reader',true,/google\.com\/reader\//i],
// ['优酷视频播放页面',true,/http:\/\/v\.youku\.com\//i],

// ['underscorejs', true, /^http:\/\/underscorejs\.org\//i],
// 例子
// 'http://*.douban.com/*',
];

blackList = blackList.concat(prefs.excludes.split(/[\n\r]+/).map(function(line) {
return line.trim();
}));


//在以下网站上允许在非顶层窗口上加载JS..比如猫扑之类的框架集网页.
var DIExclude = [
['猫扑帖子', true, /http:\/\/dzh\.mop\.com\/[a-z]{3,6}\/\d{8}\/.*\.shtml$/i],
Expand Down
48 changes: 29 additions & 19 deletions Super_preloaderPlus/super_preloaderplus_one.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// @namespace https://github.com/ywzhaiqi
// @description 预读+翻页..全加速你的浏览体验...
// @author ywzhaiqi && NLF(原作者)
// @version 6.4.4
// @version 6.4.5
// @homepageURL https://greasyfork.org/scripts/293-super-preloaderplus-one

// @grant GM_addStyle
Expand Down Expand Up @@ -40,8 +40,8 @@

// 主要用于 chrome 原生下检查更新,也可用于手动检查更新
var scriptInfo = {
version: '6.4.4',
updateTime: '2014/9/17',
version: '6.4.5',
updateTime: '2014/9/18',
homepageURL: 'https://greasyfork.org/scripts/293-super-preloaderplus-one',
downloadUrl: 'https://greasyfork.org/scripts/293-super-preloaderplus-one/code/Super_preloaderPlus_one.user.js',
metaUrl: 'https://greasyfork.org/scripts/293-super-preloaderplus-one/code/Super_preloaderPlus_one.meta.js',
Expand Down Expand Up @@ -111,20 +111,22 @@ var prefs={
debug: GM_getValue('debug', false),
enableHistory: GM_getValue('enableHistory', false), // 把下一页链接添加到历史记录
autoGetPreLink: false, // 一开始不自动查找上一页链接,改为调用时再查找
custom_siteinfo: GM_getValue('custom_siteinfo') || '[]',
excludes: GM_getValue('excludes', ''),
custom_siteinfo: GM_getValue('custom_siteinfo', '[]'),
lazyImgSrc: 'zoomfile|file|original|load-src|_src|imgsrc|real_src|src2|data-lazyload-src|data-ks-lazyload|data-lazyload|data-src|data-original|data-thumb|data-imageurl|data-defer-src|data-placeholder',
};

//黑名单,网站正则..
// 黑名单,网站正则..
var blackList=[
// ['中关村首页',false,/^http:\/\/www\.zol\.com\.cn\/(?:#.*)?$/i],
// ['Gmail', true, /mail\.google\.com/i],
// ['Google reader',true,/google\.com\/reader\//i],
// ['优酷视频播放页面',true,/http:\/\/v\.youku\.com\//i],

// ['underscorejs', true, /^http:\/\/underscorejs\.org\//i],
// 例子
// 'http://*.douban.com/*',
];

blackList = blackList.concat(prefs.excludes.split(/[\n\r]+/).map(function(line) {
return line.trim();
}));


//在以下网站上允许在非顶层窗口上加载JS..比如猫扑之类的框架集网页.
var DIExclude = [
['猫扑帖子', true, /http:\/\/dzh\.mop\.com\/[a-z]{3,6}\/\d{8}\/.*\.shtml$/i],
Expand Down Expand Up @@ -3919,7 +3921,8 @@ var setup = function(){
#sp-prefs-setup input, #sp-prefs-setup select { border:1px solid gray;padding:2px;background:white; }\
#sp-prefs-setup li { margin:0;padding:6px 0;vertical-align:middle;background:#eee;border:0 }\
#sp-prefs-setup button { width:150px;margin:0 10px;text-align:center; }\
#sp-prefs-custom_siteinfo { width:98%;height:100px;margin:3px 0; }\
#sp-prefs-setup textarea { width:98%; height:60px; margin:3px 0; }\
#sp-prefs-setup b { font-weight: bold; font-family: "微软雅黑", sans-serif; }\
');

var div = d.createElement('div');
Expand All @@ -3938,6 +3941,9 @@ var setup = function(){
<li><input type="checkbox" id="sp-prefs-SITEINFO_D-useiframe" /> 在预读模式下,默认启用 iframe 方式</li>\
<li><input type="checkbox" id="sp-prefs-SITEINFO_D-a_enable" /> 默认启用自动翻页 </li>\
<li><input type="checkbox" id="sp-prefs-SITEINFO_D-a_force_enable" /> 自动翻页默认启用强制拼接</li>\
<li>自定义排除列表:\
<div><textarea id="sp-prefs-excludes" placeholder="自定义排除列表,支持通配符。\n例如:http://*.douban.com/*"></textarea></div>\
</li>\
<li>自定义站点规则:\
<div><textarea id="sp-prefs-custom_siteinfo" placeholder="自定义站点规则"></textarea></div>\
</li>\
Expand All @@ -3963,23 +3969,28 @@ var setup = function(){
debug = xbug ? console.log.bind(console) : function() {};

GM_setValue('dblclick_pause', $('dblclick_pause').checked);

GM_setValue('excludes', prefs.excludes = $('excludes').value);
GM_setValue('custom_siteinfo', prefs.custom_siteinfo = $('custom_siteinfo').value);

SP.loadSetting();

close();
});

on($('cancel'), 'click', close);

$('checkUpdate').onclick = checkUpdate();
$('checkUpdate').onclick = checkUpdate;
$('debug').checked = xbug;
$('enableHistory').checked = prefs.enableHistory;
$('dblclick_pause').checked = GM_getValue('dblclick_pause') || false;
$('SITEINFO_D-useiframe').checked = SITEINFO_D.useiframe;
$('SITEINFO_D-a_enable').checked = SITEINFO_D.autopager.enable;
$('SITEINFO_D-a_force_enable').checked = SITEINFO_D.autopager.force_enable;
$('excludes').value = prefs.excludes;
$('custom_siteinfo').value = prefs.custom_siteinfo;

// 打开设置自动检查更新
checkUpdate();
};

function checkUpdate() {
Expand Down Expand Up @@ -5488,11 +5499,10 @@ function init(window, document) {

//执行开始..///////////////////

//分析黑名单
var item = _.find(blackList, function(x){ return x[1] && toRE(x[2]).test(url); });
if(item){
debug('匹配黑名单', item, 'js执行终止');
debug('全部过程耗时', new Date() - startTime, '毫秒');
// 分析黑名单
var blackList_re = new RegExp(blackList.map(wildcardToRegExpStr).join("|"));
if(blackList_re.test(url)){
debug('匹配黑名单,js执行终止');
return;
}

Expand Down

0 comments on commit 08aa782

Please sign in to comment.