Skip to content

Commit

Permalink
添加 violentmonkey 支持
Browse files Browse the repository at this point in the history
  • Loading branch information
kkHAIKE committed Sep 7, 2018
1 parent 33c7a31 commit 5bbbc48
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
## 安装
油猴脚本,chrome 浏览器需要安装 [tampermonkey](https://chrome.google.com/webstore/detail/dhdgffkkebhmkfjojejmpbldmpobfkfo) 插件

firfox 浏览器 57 以上版本,当前只能使用 [tampermonkey](https://addons.mozilla.org/zh-CN/firefox/addon/tampermonkey)
~~firfox 浏览器 57 以上版本,当前只能使用 [tampermonkey](https://addons.mozilla.org/zh-CN/firefox/addon/tampermonkey)~~
详情移步 https://github.com/kkHAIKE/fake115/issues/53

Safari 的 Tampermonkey 不出现密码框, 移步 https://github.com/kkHAIKE/fake115/issues/56
Expand Down
20 changes: 12 additions & 8 deletions fake115.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
// @require https://cdn.bootcss.com/crc-32/1.2.0/crc32.min.js
// @require https://cdn.bootcss.com/blueimp-md5/2.10.0/js/md5.min.js
// @require https://cdn.bootcss.com/aes-js/3.1.0/index.min.js
// @require https://rawgit.com/kkHAIKE/node-lz4/balabala/build/lz4.min.js
// @require https://rawgit.com/indutny/elliptic/master/dist/elliptic.min.js
// @require https://rawgit.com/emn178/js-md4/master/build/md4.min.js
// @require https://rawgit.com/kkHAIKE/fake115/master/fec115.min.js
// @require https://raw.github.com/kkHAIKE/node-lz4/balabala/build/lz4.min.js
// @require https://raw.github.com/indutny/elliptic/master/dist/elliptic.min.js
// @require https://raw.github.com/emn178/js-md4/master/build/md4.min.js
// @require https://raw.github.com/kkHAIKE/fake115/master/fec115.min.js
// @require https://cdn.bootcss.com/jsSHA/2.3.1/sha1.js
// @require https://rawgit.com/pierrec/js-xxhash/master/build/xxhash.min.js
// @require https://raw.github.com/pierrec/js-xxhash/master/build/xxhash.min.js
// @run-at document-start
// ==/UserScript==
(function() {
Expand Down Expand Up @@ -103,7 +103,8 @@ ec115_encode_data = (data, key) ->
rets.push Buffer.from key2

j += 16
return Buffer.concat(rets).toString 'latin1'
return Buffer.concat rets


ec115_decode_aes = (data, key) ->
key1 = key[0...16]
Expand Down Expand Up @@ -255,7 +256,7 @@ LoginEncrypt_ = ({account, passwd, environment, goto, login_type}, g, {pub, key}
GM_xmlhttpRequest
method: 'POST'
url: "http://passport.115.com/?ct=encrypt&ac=login&k_ec=#{token}" #encodeURIComponent
data: data
data: if GM_info.scriptHandler is 'Violentmonkey' then new Blob [data.buffer], {type: 'application/octet-binary'} else data.toString 'latin1'
binary: true
responseType: 'arraybuffer'
#overrideMimeType: 'text\/plain; charset=x-user-defined'
Expand Down Expand Up @@ -330,10 +331,13 @@ browserInterface.LoginEncrypt = (n,g) ->

browserInterface.GetBrowserVersion = ->
new String(g_ver)

browserInterface.ChromeGetIncognitoState = ->
false

if typeof cloneInto isnt 'function'
cloneInto = (x) -> x

unsafeWindow.browserInterface = cloneInto browserInterface, unsafeWindow, {cloneFunctions: true}

unsafeWindow.document.addEventListener 'DOMContentLoaded', ->
Expand Down
16 changes: 12 additions & 4 deletions fake115.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
// ==/UserScript==
(function() {
'use strict';
var Buffer, LZ4, LoginEncrypt_, browserInterface, bytesToHex, bytesToString, dictToForm, dictToQuery, ec115_compress_decode, ec115_decode, ec115_decode_aes, ec115_encode_data, ec115_encode_token, ec115_init, elliptic, g_ver, get_key, md4, md4_init, preLoginEncrypt, ref, sig_calc, sig_init, stringToBytes;
var Buffer, LZ4, LoginEncrypt_, browserInterface, bytesToHex, bytesToString, cloneInto, dictToForm, dictToQuery, ec115_compress_decode, ec115_decode, ec115_decode_aes, ec115_encode_data, ec115_encode_token, ec115_init, elliptic, g_ver, get_key, md4, md4_init, preLoginEncrypt, ref, sig_calc, sig_init, stringToBytes;

g_ver = '8.3.0.25';

Expand Down Expand Up @@ -127,7 +127,7 @@ ec115_encode_data = function(data, key) {
rets.push(Buffer.from(key2));
j += 16;
}
return Buffer.concat(rets).toString('latin1');
return Buffer.concat(rets);
};

ec115_decode_aes = function(data, key) {
Expand Down Expand Up @@ -304,7 +304,9 @@ LoginEncrypt_ = function(arg, g, arg1, sig) {
return GM_xmlhttpRequest({
method: 'POST',
url: "http://passport.115.com/?ct=encrypt&ac=login&k_ec=" + token,
data: data,
data: GM_info.scriptHandler === 'Violentmonkey' ? new Blob([data.buffer], {
type: 'application/octet-binary'
}) : data.toString('latin1'),
binary: true,
responseType: 'arraybuffer',
headers: {
Expand Down Expand Up @@ -396,11 +398,17 @@ browserInterface.LoginEncrypt = function(n, g) {
browserInterface.GetBrowserVersion = function() {
return new String(g_ver);
};

browserInterface.ChromeGetIncognitoState = function() {
return false;
};

if (typeof cloneInto !== 'function') {
cloneInto = function(x) {
return x;
};
}

unsafeWindow.browserInterface = cloneInto(browserInterface, unsafeWindow, {
cloneFunctions: true
});
Expand Down

0 comments on commit 5bbbc48

Please sign in to comment.