-
Notifications
You must be signed in to change notification settings - Fork 831
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' of https://github.com/ronggang/PT-Plugin-Plus into…
… dev
- Loading branch information
Showing
3 changed files
with
240 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
{ | ||
"name": "国语视界", | ||
"timezoneOffset": "+0800", | ||
"schema": "Discuz", | ||
"supportedFeatures": { | ||
"search": false, | ||
"imdbSearch": false, | ||
"sendTorrent": false | ||
}, | ||
"url": "https://cnlang.org/", | ||
"description": "国语视界音轨组,特效字幕组官方首发论坛,国语音轨和特效字幕的分享基地,蓝光DIY和4K电影爱好者的乐园。", | ||
"icon": "https://cnlang.org/favicon.ico", | ||
"tags": ["特效字幕", "国语音轨"], | ||
"collaborator": [ | ||
"fzlins" | ||
], | ||
"host": "cnlang.org", | ||
"selectors": { | ||
"userBaseInfo": { | ||
"page": "/home.php?mod=spacecp&ac=credit", | ||
"fields": { | ||
"id": { | ||
"selector": [".vwmy a"], | ||
"attribute": "href", | ||
"filters": ["query ? query.replace(/\\D+/g, '') : '' "] | ||
}, | ||
"name": { | ||
"selector": [".vwmy a"] | ||
}, | ||
"messageCount": { | ||
"selector": ["a.a.showmenu.new"], | ||
"filters": ["query.text().match(/(\\d+)/)", "(query && query.length>=2)?parseInt(query[1]):0"] | ||
}, | ||
"isLogged": { | ||
"selector": [ | ||
"a[href*='action=logout']" | ||
], | ||
"filters": [ | ||
"query.length>0" | ||
] | ||
}, | ||
"bonus": { | ||
"selector": "li:contains('大洋')", | ||
"filters": [ | ||
"query.text().match(/大洋.*?([\\d.]+)/)[1]", | ||
"parseFloat(query)" | ||
] | ||
} | ||
} | ||
}, | ||
"userExtendInfo": { | ||
"page": "/home.php?mod=spacecp&ac=plugin&id=bt_magnet:action", | ||
"fields": { | ||
"uploaded": { | ||
"selector": ".attach_magnet_div p:contains('上传量')", | ||
"filters": [ | ||
"query.text().replace('上传量:', '').trim().sizeToNumber()" | ||
] | ||
}, | ||
"downloaded": { | ||
"selector": ".attach_magnet_div p:contains('下载量')", | ||
"filters": [ | ||
"query.text().replace('下载量:', '').trim().sizeToNumber()" | ||
] | ||
}, | ||
"ratio": { | ||
"selector": ".attach_magnet_div p:contains('分享率:')", | ||
"filters": [ | ||
"query.text().replace('分享率:', '').replace(/,/g,'').trim()", | ||
"parseFloat(query)" | ||
] | ||
}, | ||
"levelName": { | ||
"selector": ["a[href='home.php?mod=spacecp&ac=usergroup']:first"], | ||
"filters": ["query.text().replace('用户组: ', '').trim()"] | ||
}, | ||
"joinTime": { | ||
"selector": ".attach_magnet_div p:contains('加入时间:')", | ||
"filters": [ | ||
"query.text().replace('加入时间:', '').trim()", | ||
"dateTime(query).isValid()?dateTime(query).valueOf():query" | ||
] | ||
} | ||
} | ||
}, | ||
"userSeedingTorrents": { | ||
"prerequisites": "!user.seeding", | ||
"page": "/home.php?mod=spacecp&ac=plugin&id=bt_magnet:action&subop=seeding", | ||
"parser": "getUserSeedingTorrents.js", | ||
"fields": { | ||
"seeding": { | ||
"selector": [".mn tr:not(:eq(0))"], | ||
"filters": ["query.length"] | ||
}, | ||
"seedingSize": { | ||
"selector": [".mn tr:not(:eq(0))"], | ||
"filters": ["jQuery.map(query.find('td:eq(1)'), (item)=>{return $(item).text();})", "_self.getTotalSize(query)"] | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
if ("".getQueryString === undefined) { | ||
String.prototype.getQueryString = function(name, split) { | ||
if (split == undefined) split = "&"; | ||
var reg = new RegExp( | ||
"(^|" + split + "|\\?)" + name + "=([^" + split + "]*)(" + split + "|$)" | ||
), | ||
r; | ||
if ((r = this.match(reg))) return decodeURI(r[2]); | ||
return null; | ||
}; | ||
} | ||
|
||
(function(options, User) { | ||
class Parser { | ||
constructor(options, dataURL) { | ||
this.options = options; | ||
this.dataURL = dataURL; | ||
this.body = null; | ||
this.rawData = ""; | ||
this.pageInfo = { | ||
count: 0, | ||
current: 1 | ||
}; | ||
this.result = { | ||
seeding: 0, | ||
seedingSize: 0 | ||
}; | ||
this.load(); | ||
} | ||
|
||
/** | ||
* 完成 | ||
*/ | ||
done() { | ||
this.options.resolve(this.result); | ||
} | ||
|
||
/** | ||
* 解析内容 | ||
*/ | ||
parse() { | ||
const doc = new DOMParser().parseFromString(this.rawData, "text/html"); | ||
// 构造 jQuery 对象 | ||
this.body = $(doc).find("body"); | ||
|
||
this.getPageInfo(); | ||
|
||
let results = new User.InfoParser(User.service).getResult( | ||
this.body, | ||
this.options.rule | ||
); | ||
|
||
if (results) { | ||
this.result.seeding += results.seeding; | ||
this.result.seedingSize += results.seedingSize; | ||
} | ||
|
||
// 是否已到最后一页 | ||
if (this.pageInfo.current < this.pageInfo.count) { | ||
this.pageInfo.current++; | ||
this.load(); | ||
} else { | ||
this.done(); | ||
} | ||
} | ||
|
||
/** | ||
* 获取页面相关内容 | ||
*/ | ||
getPageInfo() { | ||
if (this.pageInfo.count > 0) { | ||
return; | ||
} | ||
// 获取最大页码 | ||
const infos = this.body | ||
.find("input[name='custompage']") | ||
.attr("size"); | ||
if (infos) { | ||
this.pageInfo.count = parseInt(infos); | ||
} else { | ||
this.pageInfo.count = 1; | ||
} | ||
} | ||
|
||
/** | ||
* 加载当前页内容 | ||
*/ | ||
load() { | ||
let url = this.dataURL; | ||
if (this.pageInfo.current > 0) { | ||
url += "&page=" + this.pageInfo.current; | ||
} | ||
$.get(url) | ||
.done(result => { | ||
this.rawData = result; | ||
this.parse(); | ||
}) | ||
.fail(() => { | ||
this.done(); | ||
}); | ||
} | ||
} | ||
|
||
let dataURL = options.site.activeURL + options.rule.page; | ||
dataURL = dataURL | ||
.replace("$user.id$", options.userInfo.id) | ||
.replace("$user.name$", options.userInfo.name) | ||
.replace("://", "****") | ||
.replace(/\/\//g, "/") | ||
.replace("****", "://"); | ||
|
||
new Parser(options, dataURL); | ||
})(_options, _self); | ||
/** | ||
* | ||
_options 表示当前参数 | ||
{ | ||
site, | ||
rule, | ||
userInfo, | ||
resolve, | ||
reject | ||
} | ||
_self 表示 User(/src/background/user.ts) 类实例 | ||
*/ |