diff --git a/Super_preloaderPlus/Gruntfile.js b/Super_preloaderPlus/Gruntfile.js index 2fb9b2ca..05bd00df 100644 --- a/Super_preloaderPlus/Gruntfile.js +++ b/Super_preloaderPlus/Gruntfile.js @@ -12,7 +12,7 @@ module.exports = function(grunt) { concat: { dist: { options: concatOptions, - src: ['src/meta.js', 'src/rule.js', 'src/main.js'], + src: ['src/meta.js', 'src/rule.js', 'src/setting.js', 'src/main.js'], dest: '<%= pkg.name %>.user.js' }, }, @@ -61,4 +61,4 @@ module.exports = function(grunt) { grunt.loadNpmTasks('grunt-contrib-clean') grunt.loadNpmTasks('grunt-contrib-watch') -} \ No newline at end of file +} diff --git a/Super_preloaderPlus/src/main.js b/Super_preloaderPlus/src/main.js index 0ff13a1e..c1c1dcd0 100644 --- a/Super_preloaderPlus/src/main.js +++ b/Super_preloaderPlus/src/main.js @@ -76,145 +76,6 @@ var SP = { }, }; -var setup = function(){ - var d = document; - var on = function(node, e, f) { - node.addEventListener(e, f, false); - }; - - var $ = function(s) { return d.getElementById('sp-prefs-'+s); }; - if($('setup')) return; - - var styleNode = GM_addStyle('\ - #sp-prefs-setup { position:fixed;z-index:2147483647;top:30px;right:60px;padding:20px 30px;background:#eee;width:500px;border:1px solid black; }\ - #sp-prefs-setup * { color:black;text-align:left;line-height:normal;font-size:12px; }\ - #sp-prefs-setup a { color:black;text-decoration:underline; }\ - #sp-prefs-setup div { text-align:center;font-weight:bold;font-size:14px; }\ - #sp-prefs-setup ul { margin:15px 0 15px 0;padding:0;list-style:none;background:#eee;border:0; }\ - #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-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'); - div.id = 'sp-prefs-setup'; - d.body.appendChild(div); - div.innerHTML = '\ -
Super_preloaderPlus_one 设置
\ - \ -
'; - div = null; - - var close = function() { - if (styleNode) { - styleNode.parentNode.removeChild(styleNode); - } - var div = $('setup'); - div.parentNode.removeChild(div); - }; - - on($('ok'), 'click', function(){ - GM_setValue('enableHistory', prefs.enableHistory = !!$('enableHistory').checked); - GM_setValue('SITEINFO_D.useiframe', SITEINFO_D.useiframe = !!$('SITEINFO_D-useiframe').checked); - GM_setValue('SITEINFO_D.autopager.enable', SITEINFO_D.autopager.enable = !!$('SITEINFO_D-a_enable').checked); - GM_setValue('SITEINFO_D.autopager.force_enable', SITEINFO_D.autopager.force_enable = !!$('SITEINFO_D-a_force_enable').checked); - - GM_setValue('debug', xbug = !!$('debug').checked); - 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; - $('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(); -}; - -var isUpdating = true; -function checkUpdate() { - if (isUpdating) { - return; - } - - GM_xmlhttpRequest({ - method: "GET", - url: scriptInfo.metaUrl, - onload: function(response) { - var txt = response.responseText; - var curVersion = scriptInfo.version; - var latestVersion = txt.match(/@\s*version\s*([\d\.]+)\s*/i); - if (latestVersion) { - latestVersion = latestVersion[1]; - } else { - alert('解析版本号错误'); - return; - } - - //对比版本号 - var needUpdate; - var latestVersion = latestVersion.split('.'); - var lVLength = latestVersion.length; - var currentVersion = curVersion.split('.'); - var cVLength = currentVersion.length; - var lV_x; - var cV_x; - for (var i = 0; i < lVLength; i++) { - lV_x = Number(latestVersion[i]); - cV_x = (i >= cVLength) ? 0 : Number(currentVersion[i]); - if (lV_x > cV_x) { - needUpdate = true; - break; - } else if (lV_x < cV_x) { - break; - } - } - - if (needUpdate) { - alert('本脚本从版本 ' + scriptInfo.version + ' 更新到了版本 ' + latestVersion + '.\n请点击脚本主页进行安装'); - document.getElementById("sp-prefs-homepageURL").boxShadow = '0 0 2px 2px #FF5555'; - } - - isUpdating = false; - } - }); -} - function init(window, document) { var startTime = new Date(); @@ -1332,6 +1193,17 @@ function init(window, document) { imgs = getAllElements('css;img[src]', fragment); //收集所有图片 } + // 处理下一页内容部分链接是否新标签页打开 + if (prefs.forceTargetWindow) { + var arr = Array.prototype.slice.call(fragment.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'); + } + }); + } + var sepdiv = createSep(lastUrl, cplink, nextlink); if (pageElements[0] && pageElements[0].tagName == 'TR') { var insertParent = insertPoint.parentNode; diff --git a/Super_preloaderPlus/src/rule.js b/Super_preloaderPlus/src/rule.js index 80133c7b..367f0d38 100644 --- a/Super_preloaderPlus/src/rule.js +++ b/Super_preloaderPlus/src/rule.js @@ -51,6 +51,7 @@ var prefs={ sepStartN: 2, // 翻页导航上的,从几开始计数.(貌似有人在意这个,所以弄个开关出来,反正简单.-_-!!) // 新增或修改的 + forceTargetWindow: GM_getValue('forceTargetWindow', true), // 下一页的链接设置成在新标签页打开 debug: GM_getValue('debug', false), enableHistory: GM_getValue('enableHistory', false), // 把下一页链接添加到历史记录 autoGetPreLink: false, // 一开始不自动查找上一页链接,改为调用时再查找 @@ -171,6 +172,9 @@ var SITEINFO=[ if (elem.className != oClassName) elem.className = oClassName; }); + }, + filter: function() { // 在添加内容到页面后运行 + }, startFilter: function(win, doc) { // 只作用一次 // 移除 Google 重定向 @@ -2827,33 +2831,34 @@ var SITEINFO=[ } } }, - {name: 'SF在线漫画', - url:/http:\/\/comic\.sfacg\.com\/HTML\/.+/i, - siteExample:'http://comic.sfacg.com/HTML/HZDLQ/243/?p=2', - preLink:{ - startAfter:'?p=', - inc:-1, - min:1, - }, - nextLink:{ - startAfter:'?p=', - mFails:[/http:\/\/comic\.sfacg\.com\/HTML\/.+\//i,'?p=1'], - inc:1, - isLast:function(doc,win,lhref){ - var pageSel=doc.getElementById('pageSel'); - if(pageSel){ - var s2os=pageSel.options; - var s2osl=s2os.length; - if(pageSel.selectedIndex==s2osl-1)return true; - } - }, - }, - autopager:{ - pageElement:'//img[@id="curPic"]', - useiframe:true, - replaceE: 'id("Pages")' - } - }, + // 已失效 + // {name: 'SF在线漫画', + // url:/http:\/\/comic\.sfacg\.com\/HTML\/.+/i, + // siteExample:'http://comic.sfacg.com/HTML/ZXCHZ/001/#p=2', + // preLink:{ + // startAfter:'#p=', + // inc:-1, + // min:1, + // }, + // nextLink:{ + // startAfter:'#p=', + // mFails:[/http:\/\/comic\.sfacg\.com\/HTML\/.+\//i,'#p=1'], + // inc:1, + // isLast:function(doc,win,lhref){ + // var pageSel=doc.getElementById('pageSel'); + // if(pageSel){ + // var s2os=pageSel.options; + // var s2osl=s2os.length; + // if(pageSel.selectedIndex==s2osl-1)return true; + // } + // }, + // }, + // autopager:{ + // pageElement:'//img[@id="curPic"]', + // useiframe:true, + // replaceE: 'id("Pages")' + // } + // }, {name: '热血漫画', url: /^http:\/\/www\.rexuedongman\.com\/comic\//i, siteExample: 'http://www.rexuedongman.com/comic/2957/36463/index.html?p=2', diff --git a/Super_preloaderPlus/src/setting.js b/Super_preloaderPlus/src/setting.js new file mode 100644 index 00000000..30b2f4f0 --- /dev/null +++ b/Super_preloaderPlus/src/setting.js @@ -0,0 +1,158 @@ +// 主要用于 chrome 原生下检查更新,也可用于手动检查更新 +var scriptInfo = { + version: '<%= pkg.version %>', + updateTime: '<%= grunt.template.today("yyyy/m/d") %>', + 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', +}; + +var setup = function(){ + var d = document; + var on = function(node, e, f) { + node.addEventListener(e, f, false); + }; + + var $ = function(s) { return d.getElementById('sp-prefs-'+s); }; + if($('setup')) return; + + var styleNode = GM_addStyle('\ + #sp-prefs-setup { position:fixed;z-index:2147483647;top:30px;right:60px;padding:20px 30px;background:#eee;width:500px;border:1px solid black; }\ + #sp-prefs-setup * { color:black;text-align:left;line-height:normal;font-size:12px; }\ + #sp-prefs-setup a { color:black;text-decoration:underline; }\ + #sp-prefs-setup div { text-align:center;font-weight:bold;font-size:14px; }\ + #sp-prefs-setup ul { margin:15px 0 15px 0;padding:0;list-style:none;background:#eee;border:0; }\ + #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-setup textarea { width:98%; height:60px; margin:3px 0; }\ + #sp-prefs-setup b { font-weight: bold; font-family: "微软雅黑", sans-serif; }\ + #sp-prefs-setup button:disabled { color: graytext; }\ + '); + + var div = d.createElement('div'); + div.id = 'sp-prefs-setup'; + d.body.appendChild(div); + div.innerHTML = '\ +
Super_preloaderPlus_one 设置
\ + \ +
'; + div = null; + + var close = function() { + if (styleNode) { + styleNode.parentNode.removeChild(styleNode); + } + var div = $('setup'); + div.parentNode.removeChild(div); + }; + + on($('ok'), 'click', function(){ + GM_setValue('enableHistory', prefs.enableHistory = !!$('enableHistory').checked); + GM_setValue('forceTargetWindow', prefs.forceTargetWindow = !!$('forceTargetWindow').checked); + GM_setValue('SITEINFO_D.useiframe', SITEINFO_D.useiframe = !!$('SITEINFO_D-useiframe').checked); + GM_setValue('SITEINFO_D.autopager.enable', SITEINFO_D.autopager.enable = !!$('SITEINFO_D-a_enable').checked); + GM_setValue('SITEINFO_D.autopager.force_enable', SITEINFO_D.autopager.force_enable = !!$('SITEINFO_D-a_force_enable').checked); + + GM_setValue('debug', xbug = !!$('debug').checked); + 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); + + $('debug').checked = xbug; + $('enableHistory').checked = prefs.enableHistory; + $('forceTargetWindow').checked = prefs.forceTargetWindow; + $('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; + +}; + +var isUpdating = true; +function checkUpdate(button) { + if (isUpdating) { + return; + } + + button.innerHTML = '正在更新中...'; + button.disabled = 'disabled'; + + var reset = function() { + isUpdating = false; + button.innerHTML = '马上更新'; + button.disabled = ''; + }; + + GM_xmlhttpRequest({ + method: "GET", + url: scriptInfo.metaUrl, + onload: function(response) { + var txt = response.responseText; + var curVersion = scriptInfo.version; + var latestVersion = txt.match(/@\s*version\s*([\d\.]+)\s*/i); + if (latestVersion) { + latestVersion = latestVersion[1]; + } else { + alert('解析版本号错误'); + return; + } + + //对比版本号 + var needUpdate; + var latestVersions = latestVersion.split('.'); + var lVLength = latestVersions.length; + var currentVersion = curVersion.split('.'); + var cVLength = currentVersion.length; + var lV_x; + var cV_x; + for (var i = 0; i < lVLength; i++) { + lV_x = Number(latestVersions[i]); + cV_x = (i >= cVLength) ? 0 : Number(currentVersion[i]); + if (lV_x > cV_x) { + needUpdate = true; + break; + } else if (lV_x < cV_x) { + break; + } + } + + if (needUpdate) { + alert('本脚本从版本 ' + scriptInfo.version + ' 更新到了版本 ' + latestVersion + '.\n请点击脚本主页进行安装'); + document.getElementById("sp-prefs-homepageURL").boxShadow = '0 0 2px 2px #FF5555'; + } + + reset(); + } + }); + + setTimeout(reset, 30 * 1000); +} diff --git a/Super_preloaderPlus/super_preloaderplus_one.user.js b/Super_preloaderPlus/super_preloaderplus_one.user.js index aedfb7cf..0c6e2161 100644 --- a/Super_preloaderPlus/super_preloaderplus_one.user.js +++ b/Super_preloaderPlus/super_preloaderplus_one.user.js @@ -101,6 +101,7 @@ var prefs={ sepStartN: 2, // 翻页导航上的,从几开始计数.(貌似有人在意这个,所以弄个开关出来,反正简单.-_-!!) // 新增或修改的 + forceTargetWindow: GM_getValue('forceTargetWindow', true), // 下一页的链接设置成在新标签页打开 debug: GM_getValue('debug', false), enableHistory: GM_getValue('enableHistory', false), // 把下一页链接添加到历史记录 autoGetPreLink: false, // 一开始不自动查找上一页链接,改为调用时再查找 @@ -221,6 +222,9 @@ var SITEINFO=[ if (elem.className != oClassName) elem.className = oClassName; }); + }, + filter: function() { // 在添加内容到页面后运行 + }, startFilter: function(win, doc) { // 只作用一次 // 移除 Google 重定向 @@ -2877,33 +2881,34 @@ var SITEINFO=[ } } }, - {name: 'SF在线漫画', - url:/http:\/\/comic\.sfacg\.com\/HTML\/.+/i, - siteExample:'http://comic.sfacg.com/HTML/HZDLQ/243/?p=2', - preLink:{ - startAfter:'?p=', - inc:-1, - min:1, - }, - nextLink:{ - startAfter:'?p=', - mFails:[/http:\/\/comic\.sfacg\.com\/HTML\/.+\//i,'?p=1'], - inc:1, - isLast:function(doc,win,lhref){ - var pageSel=doc.getElementById('pageSel'); - if(pageSel){ - var s2os=pageSel.options; - var s2osl=s2os.length; - if(pageSel.selectedIndex==s2osl-1)return true; - } - }, - }, - autopager:{ - pageElement:'//img[@id="curPic"]', - useiframe:true, - replaceE: 'id("Pages")' - } - }, + // 已失效 + // {name: 'SF在线漫画', + // url:/http:\/\/comic\.sfacg\.com\/HTML\/.+/i, + // siteExample:'http://comic.sfacg.com/HTML/ZXCHZ/001/#p=2', + // preLink:{ + // startAfter:'#p=', + // inc:-1, + // min:1, + // }, + // nextLink:{ + // startAfter:'#p=', + // mFails:[/http:\/\/comic\.sfacg\.com\/HTML\/.+\//i,'#p=1'], + // inc:1, + // isLast:function(doc,win,lhref){ + // var pageSel=doc.getElementById('pageSel'); + // if(pageSel){ + // var s2os=pageSel.options; + // var s2osl=s2os.length; + // if(pageSel.selectedIndex==s2osl-1)return true; + // } + // }, + // }, + // autopager:{ + // pageElement:'//img[@id="curPic"]', + // useiframe:true, + // replaceE: 'id("Pages")' + // } + // }, {name: '热血漫画', url: /^http:\/\/www\.rexuedongman\.com\/comic\//i, siteExample: 'http://www.rexuedongman.com/comic/2957/36463/index.html?p=2', @@ -3842,82 +3847,13 @@ var REALPAGE_SITE_PATTERN = ['search?', 'search_', 'forum', 'thread']; //---------------------------------- -// main.js - -//------------------------下面的不要管他----------------- -/////////////////////////////////////////////////////////////////// - -var xbug = prefs.debug || GM_getValue("debug") || false; -var C = console; -var debug = xbug ? console.log.bind(console) : function() {}; - -// 变量 -var isHashchangeSite = false, - hashchangeTimer = 0; - -var SP = { - init: function() { - if(document.body.getAttribute("name") === "MyNovelReader"){ - return; - } - - this.loadSetting(); - - GM_registerMenuCommand('Super_preloaderPlus_one 设置', setup); - - // 查找是否是页面不刷新的站点 - var locationHref = location.href; - var hashSite = _.find(HashchangeSites, function(x){ return toRE(x.url).test(locationHref); }); - if (hashSite) { - isHashchangeSite = true; - hashchangeTimer = hashSite.timer; - debug('当前是页面不刷新的站点', hashSite); - setTimeout(function() { - init(window, document); - }, hashchangeTimer); - } else { - init(window, document); - } - - // 分辨率 高度 > 宽度 的是手机 - if(window.screen.height > window.screen.width){ - GM_addStyle('div.sp-separator { min-width:auto !important; }'); - } - }, - loadSetting: function(){ - var a_enable = GM_getValue('SITEINFO_D.autopager.enable'); - if (a_enable !== undefined) { - SITEINFO_D.autopager.enable = a_enable; - } - - var loadDblclickPause = function(reload){ - var dblclickPause = GM_getValue('dblclick_pause', prefs.dblclick_pause); - if (dblclickPause) { - prefs.mouseA = false; - prefs.Pbutton = [0, 0, 0]; - } - - if (reload) location.reload(); - }; - - var loadCustomSiteInfo = function() { - var infos; - try { - infos = new Function('', 'return ' + prefs.custom_siteinfo)(); - }catch(e) { - console.error('自定义站点规则错误', prefs.custom_siteinfo); - // alert('自定义站点规则错误'); - } - - if (_.isArray(infos)) { - SITEINFO = infos.concat(SITEINFO); - } - }; - - loadDblclickPause(); - - loadCustomSiteInfo(); - }, +// 主要用于 chrome 原生下检查更新,也可用于手动检查更新 +var scriptInfo = { + version: '6.4.8', + updateTime: '2014/11/17', + 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', }; var setup = function(){ @@ -3937,9 +3873,10 @@ var setup = function(){ #sp-prefs-setup ul { margin:15px 0 15px 0;padding:0;list-style:none;background:#eee;border:0; }\ #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-setup button { width:150px;margin:0 10px;text-align:center;}\ #sp-prefs-setup textarea { width:98%; height:60px; margin:3px 0; }\ #sp-prefs-setup b { font-weight: bold; font-family: "微软雅黑", sans-serif; }\ + #sp-prefs-setup button:disabled { color: graytext; }\ '); var div = d.createElement('div'); @@ -3948,13 +3885,13 @@ var setup = function(){ div.innerHTML = '\
Super_preloaderPlus_one 设置
\