From 6dabab8b19b103f60ee20402d4bb086bac15f43a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8A=B1=E7=94=9FPeA?= <626954412@qq.com> Date: Tue, 21 Mar 2017 19:21:11 +0800 Subject: [PATCH 1/6] fixed README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f0c26f6..24c2b0a 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ ## 快速链接 - 导航:[官网:pxer.pea3nut.org](http://pxer.pea3nut.org/) -- 安装:通过诸如Greasemonkey的浏览器扩展安装Pxer[稳定版](http://pxer.pea3nut.org/pxer-app/pxer-master.user.js)或[开发版](http://pxer.pea3nut.org/pxer-app/pxer-dev.user.js) +- 安装:通过诸如Greasemonkey的浏览器扩展安装Pxer[开发版(推荐)](http://pxer-app.pea3nut.org/pxer-dev.user.js)或[稳定版](http://pxer-app.pea3nut.org/pxer-master.user.js) > 稳定版支持市面上所有主流浏览器,而开发版则拥有更新的功能及更高的性能! From c491f58fa09a07464f3e8af36eb6a195e636a492 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8A=B1=E7=94=9FPeA?= <626954412@qq.com> Date: Wed, 29 Mar 2017 16:26:37 +0800 Subject: [PATCH 2/6] fix #6 --- src/app/lib.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/lib.js b/src/app/lib.js index 71b9c60..4979600 100644 --- a/src/app/lib.js +++ b/src/app/lib.js @@ -119,7 +119,7 @@ window.getPageType =function(url=document.URL){ var type =null; if(URLData.domain !=='www.pixiv.net')return 'unknown'; if(URLData.path==='/bookmark.php'){ - if(!URLData.query||!URLData.query.type){ + if(!URLData.query||URLData.query.type){ switch(URLData.query.type){ case 'user': type ='bookmark_user'; From cbb4fef5b5e54b9500afbd1153bcb8ee37da8559 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8A=B1=E7=94=9FPeA?= <626954412@qq.com> Date: Wed, 29 Mar 2017 18:12:24 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug=EF=BC=8C=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=AE=8C=E6=88=90=E5=90=8E=E6=A0=87=E9=A2=98=E9=97=AA?= =?UTF-8?q?=E7=83=81=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/class/PxerThread.1.class.js | 1 + src/app/class/PxerThreadManager.2.class.js | 2 +- src/app/lib.js | 19 ++++++++++--------- src/view/vm.js | 3 +++ 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/app/class/PxerThread.1.class.js b/src/app/class/PxerThread.1.class.js index a698431..9a8ef66 100644 --- a/src/app/class/PxerThread.1.class.js +++ b/src/app/class/PxerThread.1.class.js @@ -157,6 +157,7 @@ PxerThread.prototype['run'] =function _self(){ // 判断是否真的请求成功 var msg =PxerThread.checkRequest(URL ,XHR.responseText); if(msg !==true){ + this.state ='fail'; this.dispatch('fail' ,{ task :this.task, url :URL, diff --git a/src/app/class/PxerThreadManager.2.class.js b/src/app/class/PxerThreadManager.2.class.js index 54ea2f0..c29ccc7 100644 --- a/src/app/class/PxerThreadManager.2.class.js +++ b/src/app/class/PxerThreadManager.2.class.js @@ -105,7 +105,7 @@ PxerThreadManager.prototype['run'] =function(){ if(ptm.middleware.every(fn=>fn(ptm.taskList[ptm.pointer]))){ thread.init(ptm.taskList[ptm.pointer++]); thread.run(); - }else if(ptm.threads.every(thread=>['free','timeout'].indexOf(thread.state)!==-1)){ + }else if(ptm.threads.every(thread=>['free','fail','error'].indexOf(thread.state)!==-1)){ ptm.dispatch('load' ,ptm.taskList); }; } diff --git a/src/app/lib.js b/src/app/lib.js index 4979600..758fa9e 100644 --- a/src/app/lib.js +++ b/src/app/lib.js @@ -17,17 +17,18 @@ window.blinkTitle =function(addMsg ,spaceMsg){ var addMsg =addMsg ||'[完成] '; var spaceMsg =spaceMsg ||'[  ] '; var timer =setInterval(()=>{ - if(this.title.indexOf(addMsg) !==-1){ - this.title =this.title.replace(addMsg ,spaceMsg); - }else if(this.title.indexOf(spaceMsg) !==-1){ - this.title =this.title.replace(spaceMsg ,addMsg); + if(document.title.indexOf(addMsg) !==-1){ + document.title =document.title.replace(addMsg ,spaceMsg); + }else if(document.title.indexOf(spaceMsg) !==-1){ + document.title =document.title.replace(spaceMsg ,addMsg); }else{ - this.title =addMsg+this.title; + document.title =addMsg+document.title; }; - },300); - this.addOneEventListener('mousemove' ,()=>{ + },500); + window.addEventListener('mousemove' ,function _self(){ + window.addEventListener('mousemove' ,_self); clearInterval(timer); - this.title =this.title.replace(spaceMsg ,"").replace(addMsg ,""); + document.title =document.title.replace(spaceMsg ,"").replace(addMsg ,""); }); }; window.parseURL =function(url=document.URL){ @@ -119,7 +120,7 @@ window.getPageType =function(url=document.URL){ var type =null; if(URLData.domain !=='www.pixiv.net')return 'unknown'; if(URLData.path==='/bookmark.php'){ - if(!URLData.query||URLData.query.type){ + if(URLData.query &&URLData.query.type){ switch(URLData.query.type){ case 'user': type ='bookmark_user'; diff --git a/src/view/vm.js b/src/view/vm.js index b950602..3eee24a 100644 --- a/src/view/vm.js +++ b/src/view/vm.js @@ -44,6 +44,9 @@ afterLoad(function(){ this.pxer.on('error',(err)=>{ this.errmsg =err; }); + this.pxer.on('finishWorksTask',function(){ + window.blinkTitle(); + }); }, computed:{ pageType(){ From 0e0863a564430cbfe4db476192958a2a12761817 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8A=B1=E7=94=9FPeA?= <626954412@qq.com> Date: Wed, 29 Mar 2017 18:28:09 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E5=A2=9E=E5=8A=A0Issue=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/ISSUE_TEMPLATE.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE.md diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..7f62504 --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,23 @@ + + +## 使用的系统、浏览器、Pxer版本 + +- Windows 7 +- Firefox ESR 47.4.0 +- Pxer开发版 + +## Bug发生时的地址 + +http://www.pixiv.net/member_illust.php?id=10009740 + +## Bug发生时Pxer的状态 + +“程序状态”窗口的“当前状态”一直卡在“抓取作品中”不动,并且主面板有提示`src.match(...) is null`。 + +## Bug发生的具体情况 + +当我用Pxer抓取上面地址的画师作品时,抓取到后面的时候偶尔会(30%几率左右的样子)在差10副作品左右时卡住不动,尝试过点击`Stop`按钮依旧无效。 From a0a615f1153f1f4bfb4d87a2b468d1b768a585c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8A=B1=E7=94=9FPeA?= <626954412@qq.com> Date: Wed, 29 Mar 2017 21:28:08 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E5=A2=9E=E5=BC=BA=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E5=A4=84=E7=90=86=EF=BC=8C=E5=A2=9E=E5=8A=A0=E8=BD=BD=E5=85=A5?= =?UTF-8?q?=E6=97=B6=E7=9A=84=E9=94=99=E8=AF=AF=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/support.jstpl.ejs | 23 ++++++++++++++++++++++- src/app/class/PxerHtmlParser.class.js | 4 ++-- src/app/lib.js | 3 +++ src/app/support.js | 23 ++++++++++++++++++++++- 4 files changed, 49 insertions(+), 4 deletions(-) diff --git a/build/support.jstpl.ejs b/build/support.jstpl.ejs index f60ef6d..d4a210d 100644 --- a/build/support.jstpl.ejs +++ b/build/support.jstpl.ejs @@ -29,6 +29,26 @@ const viewScripts =/**/[]; const afterRun =/**/[]; const linkResource =/**/[]; + // 捕获载入过程的错误 + var errorCatcher = function(error){ + if(error.filename && error.filename.indexOf(window['PXER_URL']) !== -1){ + if(window['PXER_MODE'] === 'dev'){ + alert('Pxer开发版载入出错,请尝试使用稳定版'); + }else{ + prompt( + 'Pxer载入出错,请在这个地址中汇报Bug' , + 'https://github.com/pea3nut/Pxer/issues/5' + ); + } + } + ; + }; + var cancelErrorCatcher = function(){ + window.removeEventListener('error' ,errorCatcher); + }; + window.addEventListener('error' ,errorCatcher); + window.addEventListener('error' ,cancelErrorCatcher); + // 过程化载入文件 var Flow =Promise.resolve(); @@ -63,8 +83,9 @@ const linkResource =/**/[]; Flow =Flow.then(()=>execPromise(afterRun,createScript)); - // 错误处理 + // 一些收尾工作 Flow =Flow.then(()=>console.log('Pxer loaded')); + Flow =Flow.then(cancelErrorCatcher); Flow =Flow.catch(console.error); diff --git a/src/app/class/PxerHtmlParser.class.js b/src/app/class/PxerHtmlParser.class.js index 7fafacc..6dddea8 100644 --- a/src/app/class/PxerHtmlParser.class.js +++ b/src/app/class/PxerHtmlParser.class.js @@ -108,8 +108,8 @@ PxerHtmlParser.parseWorks =function(task){ window['PXER_ERROR'] =`PxerHtmlParser.parsePage: count not parse task url "${url}"`; }; }catch(e){ - window['PXER_ERROR'] =e.message; - if(window['PXER_MODE']==='dev')console.error(e); + window['PXER_ERROR'] =`${task.id}:${e.message}`; + if(window['PXER_MODE']==='dev')console.error(task ,e); return false; } }; diff --git a/src/app/lib.js b/src/app/lib.js index 758fa9e..5d834bf 100644 --- a/src/app/lib.js +++ b/src/app/lib.js @@ -111,6 +111,7 @@ window.execPromise =function(taskList,call){ * - works_big 查看某个作品的某张图片的大图 * - member_works 自己/其他人作品列表页 * - search 检索页 + * - index 首页 * - unknown 未知 * @param {string} url * @return {string} - 页面类型 @@ -153,6 +154,8 @@ window.getPageType =function(url=document.URL){ } }else if(URLData.path==='/search.php'){ type ='search'; + }else if(URLData.path==='/'){ + type ='index'; }else{ type ='unknown'; } diff --git a/src/app/support.js b/src/app/support.js index 761ba43..61fcf43 100644 --- a/src/app/support.js +++ b/src/app/support.js @@ -58,6 +58,26 @@ const linkResource =/**/[ "src/public/favicon.ico" ];//*/[]; + // 捕获载入过程的错误 + var errorCatcher = function(error){ + if(error.filename && error.filename.indexOf(window['PXER_URL']) !== -1){ + if(window['PXER_MODE'] === 'dev'){ + alert('Pxer开发版载入出错,请尝试使用稳定版'); + }else{ + prompt( + 'Pxer载入出错,请在这个地址中汇报Bug' , + 'https://github.com/pea3nut/Pxer/issues/5' + ); + } + } + ; + }; + var cancelErrorCatcher = function(){ + window.removeEventListener('error' ,errorCatcher); + }; + window.addEventListener('error' ,errorCatcher); + window.addEventListener('error' ,cancelErrorCatcher); + // 过程化载入文件 var Flow =Promise.resolve(); @@ -92,8 +112,9 @@ const linkResource =/**/[ Flow =Flow.then(()=>execPromise(afterRun,createScript)); - // 错误处理 + // 一些收尾工作 Flow =Flow.then(()=>console.log('Pxer loaded')); + Flow =Flow.then(cancelErrorCatcher); Flow =Flow.catch(console.error); From ec3c4c122edc8950e0336f54e8e8af14317b0392 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8A=B1=E7=94=9FPeA?= <626954412@qq.com> Date: Wed, 29 Mar 2017 21:49:45 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E9=87=8A=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 +++- dist/lib.js | 24 +++++++++++++----------- dist/pxer-core.js | 7 ++++--- dist/support.js | 19 ++++++++++++++++++- dist/view/vm.js | 3 +++ 5 files changed, 41 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 24c2b0a..2331661 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,8 @@ 不仅人人可用,且代码经过精心注释可供参考~ +> 文档尚未完善 + ## 快速链接 @@ -36,7 +38,7 @@ Pxer最大作用是将pixiv.net网站(类似于花瓣网)中的图片作品 1. 在[Pixiv网站](http://www.pixiv.net)登陆注册一个账号 2. 打开“[机器猫 - 哆啦A梦](http://www.pixiv.net/search.php?s_mode=s_tag&word=%E3%83%89%E3%83%A9%E3%81%88%E3%82%82%E3%82%93%20000user)”的图片检索页面 -3. 在浏览器运行[pxer.user.js](http://pxer.pea3nut.org/pxer-app/pxer-dev.user.js)代码(将代码文件复制到控制台运行或存成书签点击运行) +3. 在浏览器运行[pxer.user.js](http://pxer-app.pea3nut.org/pxer-dev.user.js)代码(将代码文件复制到控制台运行或存成书签点击运行) 4. 操作页面中Pxer UI界面 ## 阅读源码 diff --git a/dist/lib.js b/dist/lib.js index 8ec6810..7e07641 100644 --- a/dist/lib.js +++ b/dist/lib.js @@ -15,22 +15,21 @@ window.setDefalut = function (obj, key, val) { return true; }; window.blinkTitle = function (addMsg, spaceMsg) { - var _this = this; - var addMsg = addMsg || '[完成] '; var spaceMsg = spaceMsg || '[  ] '; var timer = setInterval(function () { - if (_this.title.indexOf(addMsg) !== -1) { - _this.title = _this.title.replace(addMsg, spaceMsg); - } else if (_this.title.indexOf(spaceMsg) !== -1) { - _this.title = _this.title.replace(spaceMsg, addMsg); + if (document.title.indexOf(addMsg) !== -1) { + document.title = document.title.replace(addMsg, spaceMsg); + } else if (document.title.indexOf(spaceMsg) !== -1) { + document.title = document.title.replace(spaceMsg, addMsg); } else { - _this.title = addMsg + _this.title; + document.title = addMsg + document.title; }; - }, 300); - this.addOneEventListener('mousemove', function () { + }, 500); + window.addEventListener('mousemove', function _self() { + window.addEventListener('mousemove', _self); clearInterval(timer); - _this.title = _this.title.replace(spaceMsg, "").replace(addMsg, ""); + document.title = document.title.replace(spaceMsg, "").replace(addMsg, ""); }); }; window.parseURL = function () { @@ -196,6 +195,7 @@ window.execPromise = function (taskList, call) { * - works_big 查看某个作品的某张图片的大图 * - member_works 自己/其他人作品列表页 * - search 检索页 + * - index 首页 * - unknown 未知 * @param {string} url * @return {string} - 页面类型 @@ -207,7 +207,7 @@ window.getPageType = function () { var type = null; if (URLData.domain !== 'www.pixiv.net') return 'unknown'; if (URLData.path === '/bookmark.php') { - if (!URLData.query || !URLData.query.type) { + if (URLData.query && URLData.query.type) { switch (URLData.query.type) { case 'user': type = 'bookmark_user'; @@ -240,6 +240,8 @@ window.getPageType = function () { } } else if (URLData.path === '/search.php') { type = 'search'; + } else if (URLData.path === '/') { + type = 'index'; } else { type = 'unknown'; } diff --git a/dist/pxer-core.js b/dist/pxer-core.js index c48a7bd..bd9e7b8 100644 --- a/dist/pxer-core.js +++ b/dist/pxer-core.js @@ -634,8 +634,8 @@ PxerHtmlParser.parseWorks = function (task) { window['PXER_ERROR'] = 'PxerHtmlParser.parsePage: count not parse task url "' + url + '"'; }; } catch (e) { - window['PXER_ERROR'] = e.message; - if (window['PXER_MODE'] === 'dev') console.error(e); + window['PXER_ERROR'] = task.id + ':' + e.message; + if (window['PXER_MODE'] === 'dev') console.error(task, e); return false; } }; @@ -1206,6 +1206,7 @@ PxerThread.prototype['run'] = function _self() { // 判断是否真的请求成功 var msg = PxerThread.checkRequest(URL, XHR.responseText); if (msg !== true) { + _this6.state = 'fail'; _this6.dispatch('fail', { task: _this6.task, url: URL, @@ -1387,7 +1388,7 @@ PxerThreadManager.prototype['run'] = function () { thread.init(ptm.taskList[ptm.pointer++]); thread.run(); } else if (ptm.threads.every(function (thread) { - return ['free', 'timeout'].indexOf(thread.state) !== -1; + return ['free', 'fail', 'error'].indexOf(thread.state) !== -1; })) { ptm.dispatch('load', ptm.taskList); }; diff --git a/dist/support.js b/dist/support.js index 9452288..2101e6c 100644 --- a/dist/support.js +++ b/dist/support.js @@ -34,6 +34,22 @@ var afterRun = /**/"dist/run.js"; //*/[]; var linkResource = /**/["dist/public/favicon.ico"]; //*/[]; + // 捕获载入过程的错误 + var errorCatcher = function errorCatcher(error) { + if (error.filename && error.filename.indexOf(window['PXER_URL']) !== -1) { + if (window['PXER_MODE'] === 'dev') { + alert('Pxer开发版载入出错,请尝试使用稳定版'); + } else { + prompt('Pxer载入出错,请在这个地址中汇报Bug', 'https://github.com/pea3nut/Pxer/issues/5'); + } + } + ; + }; + var cancelErrorCatcher = function cancelErrorCatcher() { + window.removeEventListener('error', errorCatcher); + }; + window.addEventListener('error', errorCatcher); + window.addEventListener('error', cancelErrorCatcher); // 过程化载入文件 var Flow = Promise.resolve(); @@ -78,9 +94,10 @@ return execPromise(afterRun, createScript); }); - // 错误处理 + // 一些收尾工作 Flow = Flow.then(function () { return console.log('Pxer loaded'); }); + Flow = Flow.then(cancelErrorCatcher); Flow = Flow.catch(console.error); }(); \ No newline at end of file diff --git a/dist/view/vm.js b/dist/view/vm.js index 06a68f3..ffe0660 100644 --- a/dist/view/vm.js +++ b/dist/view/vm.js @@ -50,6 +50,9 @@ afterLoad(function () { this.pxer.on('error', function (err) { _this.errmsg = err; }); + this.pxer.on('finishWorksTask', function () { + window.blinkTitle(); + }); }, computed: {