Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
pea3nut committed Mar 29, 2017
2 parents 2956fa5 + ec3c4c1 commit 0e1e744
Show file tree
Hide file tree
Showing 13 changed files with 129 additions and 31 deletions.
23 changes: 23 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!--
你正创建一个新的Issue
若你使用此Issue反馈Bug,请参考下面给出的模板,然后自行修改对应信息。
如果是其他用途,请清空此文本框。
-->

## 使用的系统、浏览器、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`按钮依旧无效。
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@

不仅人人可用,且代码经过精心注释可供参考~

> 文档尚未完善
<img src="/src/public/pxer-ui-gif.gif?raw=true" />

## 快速链接

- 导航:[官网: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)

> 稳定版支持市面上所有主流浏览器,而开发版则拥有更新的功能及更高的性能!
Expand All @@ -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界面

## 阅读源码
Expand Down
23 changes: 22 additions & 1 deletion build/support.jstpl.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,26 @@ const viewScripts =/*<?-viewScripts?>*/[];
const afterRun =/*<?-afterRun?>*/[];
const linkResource =/*<?-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();
Expand Down Expand Up @@ -63,8 +83,9 @@ const linkResource =/*<?-linkResource?>*/[];
Flow =Flow.then(()=>execPromise(afterRun,createScript));


// 错误处理
// 一些收尾工作
Flow =Flow.then(()=>console.log('Pxer loaded'));
Flow =Flow.then(cancelErrorCatcher);
Flow =Flow.catch(console.error);


Expand Down
24 changes: 13 additions & 11 deletions dist/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down Expand Up @@ -196,6 +195,7 @@ window.execPromise = function (taskList, call) {
* - works_big 查看某个作品的某张图片的大图
* - member_works 自己/其他人作品列表页
* - search 检索页
* - index 首页
* - unknown 未知
* @param {string} url
* @return {string} - 页面类型
Expand All @@ -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';
Expand Down Expand Up @@ -240,6 +240,8 @@ window.getPageType = function () {
}
} else if (URLData.path === '/search.php') {
type = 'search';
} else if (URLData.path === '/') {
type = 'index';
} else {
type = 'unknown';
}
Expand Down
7 changes: 4 additions & 3 deletions dist/pxer-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
};
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
};
Expand Down
19 changes: 18 additions & 1 deletion dist/support.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}();
3 changes: 3 additions & 0 deletions dist/view/vm.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ afterLoad(function () {
this.pxer.on('error', function (err) {
_this.errmsg = err;
});
this.pxer.on('finishWorksTask', function () {
window.blinkTitle();
});
},

computed: {
Expand Down
4 changes: 2 additions & 2 deletions src/app/class/PxerHtmlParser.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
};
Expand Down
1 change: 1 addition & 0 deletions src/app/class/PxerThread.1.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/app/class/PxerThreadManager.2.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
}
Expand Down
22 changes: 13 additions & 9 deletions src/app/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down Expand Up @@ -110,6 +111,7 @@ window.execPromise =function(taskList,call){
* - works_big 查看某个作品的某张图片的大图
* - member_works 自己/其他人作品列表页
* - search 检索页
* - index 首页
* - unknown 未知
* @param {string} url
* @return {string} - 页面类型
Expand All @@ -119,7 +121,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';
Expand Down Expand Up @@ -152,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';
}
Expand Down
23 changes: 22 additions & 1 deletion src/app/support.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);


Expand Down
3 changes: 3 additions & 0 deletions src/view/vm.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ afterLoad(function(){
this.pxer.on('error',(err)=>{
this.errmsg =err;
});
this.pxer.on('finishWorksTask',function(){
window.blinkTitle();
});
},
computed:{
pageType(){
Expand Down

0 comments on commit 0e1e744

Please sign in to comment.