Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
.Veneno.
wechaty
提交
97e5d9a5
W
wechaty
项目概览
.Veneno.
/
wechaty
与 Fork 源项目一致
Fork自
wechaty / wechaty
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
W
wechaty
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
97e5d9a5
编写于
8月 07, 2016
作者:
Huan (李卓桓)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
upgrade to compatible with selenium-webdriver v3
上级
2321d566
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
27 addition
and
21 deletion
+27
-21
package.json
package.json
+3
-2
src/puppet-web/browser.js
src/puppet-web/browser.js
+24
-19
未找到文件。
package.json
浏览文件 @
97e5d9a5
{
"name"
:
"wechaty"
,
"version"
:
"0.3.
3
"
,
"version"
:
"0.3.
5
"
,
"description"
:
"Wechat for Bot (Personal Account)"
,
"main"
:
"index.js"
,
"scripts"
:
{
...
...
@@ -8,7 +8,8 @@
"pretest"
:
"npm run lint"
,
"start"
:
"node bin/io-bot"
,
"demo"
:
"node example/ding-dong-bot.js"
,
"test"
:
"cross-env TAP_TIMEOUT=600 tap --reporter=tap test/{*,**/*}.spec.js"
"prepublish"
:
"npm shrinkwrap"
,
"test"
:
"cross-env TAP_TIMEOUT=600 tap --reporter=tap test/**/*.spec.js"
},
"repository"
:
{
"type"
:
"git"
,
...
...
src/puppet-web/browser.js
浏览文件 @
97e5d9a5
...
...
@@ -254,7 +254,7 @@ class Browser extends EventEmitter {
addCookies
(
cookie
)
{
if
(
this
.
dead
())
{
return
Promise
.
reject
(
new
Error
(
'
addCookies() - browser dead
'
))}
if
(
cookie
.
map
)
{
if
(
typeof
cookie
.
map
===
'
function
'
)
{
return
cookie
.
map
(
c
=>
{
return
this
.
addCookies
(
c
)
})
...
...
@@ -265,15 +265,16 @@ class Browser extends EventEmitter {
* NOTICE: the lastest branch of selenium-webdriver for js has changed the interface of addCookie:
* https://github.com/SeleniumHQ/selenium/commit/02f407976ca1d516826990f11aca7de3c16ba576
*/
if
(
cookie
.
expiry
)
{
cookie
.
expiry
=
cookie
.
expiry
*
1000
/* XXX: be aware of new version of webdriver */
}
//
if (cookie.expiry) { cookie.expiry = cookie.expiry * 1000 /* XXX: be aware of new version of webdriver */}
log
.
silly
(
'
PuppetWebBrowser
'
,
'
addCookies("%s", "%s", "%s", "%s", "%s", "%s")
'
,
cookie
.
name
,
cookie
.
value
,
cookie
.
path
,
cookie
.
domain
,
cookie
.
secure
,
cookie
.
expiry
)
log
.
silly
(
'
PuppetWebBrowser
'
,
'
addCookies("%s")
'
,
JSON
.
stringify
(
cookie
))
return
this
.
driver
.
manage
()
.
addCookie
(
cookie
.
name
,
cookie
.
value
,
cookie
.
path
,
cookie
.
domain
,
cookie
.
secure
,
cookie
.
expiry
)
// this is old webdriver format
// .addCookie(cookie.name, cookie.value, cookie.path
// , cookie.domain, cookie.secure, cookie.expiry)
// thisi is new webdriver format
.
addCookie
(
cookie
)
.
catch
(
e
=>
{
log
.
warn
(
'
PuppetWebBrowser
'
,
'
addCookies() exception: %s
'
,
e
.
message
)
throw
e
...
...
@@ -400,20 +401,24 @@ class Browser extends EventEmitter {
const
filename
=
this
.
sessionFile
function
cookieFilter
(
cookies
)
{
const
skipNames
=
[
'
ChromeDriver
'
,
'
MM_WX_SOUND_STATE
'
,
'
MM_WX_NOTIFY_STATE
'
]
const
skipNamesRegex
=
new
RegExp
(
skipNames
.
join
(
'
|
'
),
'
i
'
)
return
cookies
.
filter
(
c
=>
{
if
(
skipNamesRegex
.
test
(
c
.
name
))
{
return
false
}
// else if (!/wx\.qq\.com/i.test(c.domain)) { return false }
else
{
return
true
}
})
}
return
new
Promise
((
resolve
,
reject
)
=>
{
this
.
driver
.
manage
().
getCookies
()
.
then
(
allCookies
=>
{
const
skipNames
=
[
'
ChromeDriver
'
,
'
MM_WX_SOUND_STATE
'
,
'
MM_WX_NOTIFY_STATE
'
]
const
skipNamesRegex
=
new
RegExp
(
skipNames
.
join
(
'
|
'
),
'
i
'
)
const
cookies
=
allCookies
.
filter
(
c
=>
{
if
(
skipNamesRegex
.
test
(
c
.
name
))
{
return
false
}
// else if (!/wx\.qq\.com/i.test(c.domain)) { return false }
else
{
return
true
}
})
.
then
(
cookieFilter
)
.
then
(
cookies
=>
{
// log.silly('PuppetWeb', 'saving %d cookies for session: %s', cookies.length
// , util.inspect(cookies.map(c => { return {name: c.name /*, value: c.value, expiresType: typeof c.expires, expires: c.expires*/} })))
log
.
silly
(
'
PuppetWebBrowser
'
,
'
saving %d cookies for session: %s
'
,
cookies
.
length
,
cookies
.
map
(
c
=>
c
.
name
).
join
(
'
,
'
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录