oyyd/youdao-collins-chrome-extension

加到生词本的单词在扇贝的什么位置?

beetaa opened this issue · 15 comments

添加的生词保存在扇贝的哪里?谢谢。

+1,也没有看见,而且把某个词加入生词本,再刷新页面,再看那个词还是未加入生词本

+1,添加单词到扇贝词库的功能似乎失效了

oyyd commented

感谢提醒。我需要debug一下,希望不要是扇贝api变动导致的。

oyyd commented

应该只是暂时的服务不可用。我会在添加失败后给出失败的提示。

@oyyd 特意测试了一下,插件添加时显示成功(单词本图标的+号消失),但查单词本时没有发现新增单词。在扇贝网页手动搜索添加,所添加单词即可显示在单词本中。我猜测是否扇贝的api已更改了,导致添加单词失败?

oyyd commented

“单词本图标的+号消失”是因为没有比较。虽然可以通过实现请求api查看当前单词是否加入过了,但是这样需要在每个单词搜索时都发一次这个请求,我没考虑好到底要不要这么做(或者考虑只是在浏览器中维护一个添加过的单词列表)。

添加单词没有失败的话,应该会出现在“今日单词”里面。

插件添加单词到扇贝词库的功能确实失效了,原因不明。
我拿了个单词做测试,先用插件查词并添加,再到扇贝网页上查词并添加,第一步插件添加失败了,所以第二步网页添加才能成功。

看抓包的请求数据吧。
这是用插件查词的:

GET https://api.shanbay.com/bdc/search/?word=generally&access_token=****** HTTP/1.1
Host: api.shanbay.com
Connection: keep-alive
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.109 Safari/537.36
Accept: */*
DNT: 1
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.6,en;q=0.4

HTTP/1.1 200 OK
Date: Sat, 24 Jun 2017 13:51:09 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
Vary: Accept, Accept-Language, Cookie
Content-Language: zh-cn
Allow: GET
Set-Cookie: username=; expires=Thu, 01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/
Set-Cookie: userid=; expires=Thu, 01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/

43b
{"msg": "SUCCESS", "status_code": 0, "data": {"pronunciations": {"uk": "'d\u0292enr\u0259li", "us": "'d\u0292enr\u0259li"}, "en_definitions": {"adv": ["usually; as a rule", "without distinction of one from others", "without regard to specific details or exceptions"]}, "audio_addresses": {"uk": ["https://media-audio1.baydn.com/uk%2Fg%2Fge%2Fgenerally_v3.mp3", "http://media-audio1.qiniu.baydn.com/uk/g/ge/generally_v3.mp3"], "us": ["https://media-audio1.baydn.com/us%2Fg%2Fge%2Fgenerally_v3.mp3", "http://media-audio1.qiniu.baydn.com/us/g/ge/generally_v3.mp3"]}, "uk_audio": "http://media.shanbay.com/audio/uk/generally.mp3", "conent_id": 2825, "audio_name": "generally_v3", "cn_definition": {"pos": "", "defn": "adv. \u4e00\u822c\u5730"}, "num_sense": 1, "content_type": "vocabulary", "sense_id": 0, "id": 2825, "definition": " adv. \u4e00\u822c\u5730", "content_id": 2825, "url": "https://www.shanbay.com/bdc/mobile/preview/word?word=generally", "has_audio": true, "en_definition": {"pos": "adv", "defn": "usually; as a rule; without distinction of one from others; without regard
113
 to specific details or exceptions"}, "object_id": 2825, "content": "generally", "pron": "'d\u0292enr\u0259li", "pronunciation": "'d\u0292enr\u0259li", "audio": "http://media.shanbay.com/audio/us/generally.mp3", "us_audio": "http://media.shanbay.com/audio/us/generally.mp3"}}
0

------------------------------------------------------------------

POST https://api.shanbay.com/bdc/learning/?access_token=###### HTTP/1.1
Host: api.shanbay.com
Connection: keep-alive
Content-Length: 59
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.109 Safari/537.36
Origin: null
content-type: application/json
Accept: */*
DNT: 1
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.6,en;q=0.4

{"id":2825,"access_token":"******"}
HTTP/1.1 200 OK
Date: Sat, 24 Jun 2017 13:51:09 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
Vary: Accept, Accept-Language, Cookie
Content-Language: zh-cn
Allow: GET, PUT, POST, DELETE
Set-Cookie: username=; expires=Thu, 01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/
Set-Cookie: userid=; expires=Thu, 01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/

41
{"msg": "SUCCESS", "status_code": 0, "data": {"id": 50589384799}}
0

这是扇贝网页上查词的:

GET https://www.shanbay.com/api/v1/bdc/search/?version=2&word=generally&_=1498317525660 HTTP/1.1
Host: www.shanbay.com
Connection: keep-alive
Accept: application/json, text/javascript, */*; q=0.01
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.109 Safari/537.36
DNT: 1
Referer: https://www.shanbay.com/bdc/learnings/library/
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.6,en;q=0.4
Cookie: _ga=GA1.2.272344703.1498116164; sessionid=".eJyrVopPLC3JiC8tTi2KT0pMzk7NS1GyUkrOz83Nz9MDS0FFi_VccxMzc3zy0zPznKAKdZB1ZwI1GlkaGBkbmlrWAgC4BB9v:1dNwRy:-XhRAKDsksYuTFdo_f9u5fFAnnw"; csrftoken=ElRxn9LOBZCL7REinz1vty4ScKUlMVqH; language_code=zh-CN; auth_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6Imh5eHhzZnd5IiwiZGV2aWNlIjowLCJpc19zdGFmZiI6ZmFsc2UsImlkIjoyOTAyMzE1OSwiZXhwIjoxNDk5MTgxNDU3fQ.nUZveND6Y0MBgsmcTU5UTXeAPHW057x0nf4LC0o5TJQ; userid=29023159


HTTP/1.1 200 OK
Date: Sat, 24 Jun 2017 15:18:43 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
Vary: Accept, Accept-Language
Content-Language: zh-cn
Allow: GET
Set-Cookie: userid=29023159; Path=/
X-Frame-Options: DENY

35c
{"msg": "SUCCESS", "status_code": 0, "data": {"pronunciations": {"uk": "'d\u0292enr\u0259li", "us": "'d\u0292enr\u0259li"}, "content": "generally", "num_sense": 3, "audio_addresses": {"uk": ["https://media-audio1.baydn.com/uk%2Fg%2Fge%2Fgenerally_v3.mp3", "http://media-audio1.qiniu.baydn.com/uk/g/ge/generally_v3.mp3"], "us": ["https://media-audio1.baydn.com/us%2Fg%2Fge%2Fgenerally_v3.mp3", "http://media-audio1.qiniu.baydn.com/us/g/ge/generally_v3.mp3"]}, "url": "https://www.shanbay.com/bdc/mobile/preview/word?word=generally", "definitions": {"en": [{"pos": "adv.", "defn": "usually; as a rule"}, {"pos": "adv.", "defn": "without distinction of one from others"}, {"pos": "adv.", "defn": "without regard to specific details or exceptions"}], "cn": [{"pos": "adv.", "defn": "\u4e00\u822c\u5730"}]}, "sense_id": 0, "id": 2825, "audio_name": "generally_v3"}}
0

------------------------------------------------------------------

POST https://www.shanbay.com/api/v1/bdc/learning/ HTTP/1.1
Host: www.shanbay.com
Connection: keep-alive
Content-Length: 39
Accept: application/json, text/javascript, */*; q=0.01
Origin: https://www.shanbay.com
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.109 Safari/537.36
Content-Type: application/json
DNT: 1
Referer: https://www.shanbay.com/bdc/learnings/library/
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.6,en;q=0.4
Cookie: _ga=GA1.2.272344703.1498116164; sessionid=".eJyrVopPLC3JiC8tTi2KT0pMzk7NS1GyUkrOz83Nz9MDS0FFi_VccxMzc3zy0zPznKAKdZB1ZwI1GlkaGBkbmlrWAgC4BB9v:1dNwRy:-XhRAKDsksYuTFdo_f9u5fFAnnw"; csrftoken=ElRxn9LOBZCL7REinz1vty4ScKUlMVqH; language_code=zh-CN; auth_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6Imh5eHhzZnd5IiwiZGV2aWNlIjowLCJpc19zdGFmZiI6ZmFsc2UsImlkIjoyOTAyMzE1OSwiZXhwIjoxNDk5MTgxNDU3fQ.nUZveND6Y0MBgsmcTU5UTXeAPHW057x0nf4LC0o5TJQ; userid=29023159

{"id":2825,"content_type":"vocabulary"}
HTTP/1.1 200 OK
Date: Sat, 24 Jun 2017 15:18:46 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
Vary: Accept, Accept-Language
Content-Language: zh-cn
Allow: GET, PUT, POST, DELETE
Set-Cookie: userid=29023159; Path=/
Access-Control-Allow-Origin: https://www.shanbay.com
Access-Control-Allow-Methods: GET, POST, OPTIONS, DELETE, PUT
Access-Control-Allow-Headers: DNT,X-Csrftoken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type
Access-Control-Allow-Credentials: true

41
{"msg": "SUCCESS", "status_code": 0, "data": {"id": 50591033344}}
0

看服务器的返回值,两次添加单词应该是都成功了的。然而这不合逻辑,扇贝的词库并不会重复添加同一个单词。事实上目前用插件添加单词的确失效了,原因不明……

oyyd commented

@beetaa @hyxxsfwy 感谢细心的回复。昨天早上看似恢复了,但确实还是有问题。

oyyd commented

是项目代码的原因,是因为我误用了token导致的(而且我自己的帐户还发现不了,尴尬)。

已经修复发布1.1.3版本,约一个小时后可以在chrome store上看到。没有关闭自动更新的话,稍后chrome应该也会自动更新版本。

感谢作者的辛勤付出!

难怪抓包看到的 POST 请求带的 token 跟下面字段里的不一样,话说兄弟你的 token 该换了,这几天我们在插件里添加的单词不会都进到你的词库里了吧……
奇怪的是,服务器的返回值还是成功的,而且之前都是可以添加单词的,就这几天开始不行了。看来扇贝是修了 API 的 BUG,然而并没有修完~~

oyyd commented

@hyxxsfwy 对,我的猜测跟你是一样的。给各位带来了困扰,非常抱歉(我自己偶然看到了token的字符串也是非常惊讶)。

我帐户的token会换掉,感谢提醒。

真的解决了吗?我确认版本是1.1.3但是还是添加单词本失败
不过这次不用刷新直接再次查询就能看到“添加到单词本”的图标还是有绿色的加号,之前的版本是需要刷新才能看到(尽管都是实际上没有添加成功)

确实已经解决了,作者代码上的小失误而已。如果无法添加,请检查你的扇贝账户授权,可以在插件设置里退出并重新登录。另外,检查自己的网络连接,还有对扇贝网的请求是否被其他扩展屏蔽了之类的。

oyyd commented

@dc3671 感谢反馈。

加入的单词应该会出现在 “单词” -> “我的词库” -> "今日单词"里。

“绿色加号”的问题,应该是刷新以后就会重新出现。因为实际上插件没办法维护一个有效的单词列表来确定一个被查询的单词是否已经被加入,所以需要在用户即便不打算加入单词本也多发一个请求来判断当前用户是否加入了这个单词,这会让查询扇贝api会让请求数量直接x2。而且因为需要确保token的有效性,要吗就是在token无效时要求用户重新登录,要吗就是在token无效时也不去判断用户是否添加了这个单词,怎么样都不是比较完美的解决办法。但是现在看来这个问题还是困扰太多人了。