下载地址
[content_hide]
第一步:下载安卓浏览器,这个浏览器已经包含了油猴插件了。
第二步:安装完成后,点右下角,附加组件,那里找到附加组件管理器,再找到Tampermonker,就基本成功一大半了
第三步:启用游猴脚本,点击管理面板,点击新建用户脚本,把代码全部删除,复制这些代码就完成了。
代码如下
// ==UserScript==
// @name 115转存助手ui优化版
// @name:zh 115转存助手ui优化版
// @author Never4Ever
// @namespace Fake115Upload@Never4Ever
// @version 1.4.3.20201230
// @description 115文件转存((based on Fake115Upload 1.4.3 @T3rry))
// @match https://115.com/*
// @grant GM_xmlhttpRequest
// @grant GM_log
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_setClipboard
// @grant unsafeWindow
// @connect proapi.115.com
// @connect webapi.115.com
// @connect 115.com
// @require https://cdn.bootcss.com/jsSHA/2.3.1/sha1.js
// @require https://greasyfork.org/scripts/5392-waitforkeyelements/code/WaitForKeyElements.js?version=115012
// @require https://cdn.jsdelivr.net/npm/sweetalert2@8
// @require https://cdn.jsdelivr.net/npm/node-forge@0.10.0/dist/forge.min.js
// @downloadURL none
// ==/UserScript==
/*********************************************
log:
>20201230
...*使用大神的最新脚本的提取接口,salute!
>20201124
...*提取sha1时的ui优化(如果界面卡住太长时间,请重试)
>20201114
...*转存和提取时ui提示增加和优化
>20201112
...*转存时添加进度条以及提示
>20201103
...* 优化转存目录选择: 行为跟下载一致,可以自行选择(可能会触发逻辑bug= =。。)
>20201015
...* 修复不能自动存到“转存”目录的问题
+++++++++++++++++++++++++++++++++++++++++++++++
todo:(计划中。。。)
*) 转存和提取时ui优化
*) 根据大小或者类型提取
*) 按目录提取和转存
***********************************************/
(function () {
'use strict';
//#region 20201230新的提取api相关
var pub_key = '-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDR3rWmeYnRClwLBB0Rq0dlm8Mr
PmWpL5I23SzCFAoNpJX6Dn74dfb6y02YH15eO6XmeBHdc7ekEFJUIi+swganTokR
IVRRr/z16/3oh7ya22dcAqg191y+d6YDr4IGg/Q5587UKJMj35yQVXaeFXmLlFPo
kFiz4uPxhrB7BGqZbQIDAQAB
-----END PUBLIC KEY-----'
var private_key = '-----BEGIN RSA PRIVATE KEY-----
MIICXAIBAAKBgQCMgUJLwWb0kYdW6feyLvqgNHmwgeYYlocst8UckQ1+waTOKHFC
TVyRSb1eCKJZWaGa08mB5lEu/asruNo/HjFcKUvRF6n7nYzo5jO0li4IfGKdxso6
FJIUtAke8rA2PLOubH7nAjd/BV7TzZP2w0IlanZVS76n8gNDe75l8tonQQIDAQAB
AoGANwTasA2Awl5GT/t4WhbZX2iNClgjgRdYwWMI1aHbVfqADZZ6m0rt55qng63/
3NsjVByAuNQ2kB8XKxzMoZCyJNvnd78YuW3Zowqs6HgDUHk6T5CmRad0fvaVYi6t
viOkxtiPIuh4QrQ7NUhsLRtbH6d9s1KLCRDKhO23pGr9vtECQQDpjKYssF+kq9iy
A9WvXRjbY9+ca27YfarD9WVzWS2rFg8MsCbvCo9ebXcmju44QhCghQFIVXuebQ7Q
pydvqF0lAkEAmgLnib1XonYOxjVJM2jqy5zEGe6vzg8aSwKCYec14iiJKmEYcP4z
DSRms43hnQsp8M2ynjnsYCjyiegg+AZ87QJANuwwmAnSNDOFfjeQpPDLy6wtBeft
5VOIORUYiovKRZWmbGFwhn6BQL+VaafrNaezqUweBRi1PYiAF2l3yLZbUQJAf/nN
4Hz/pzYmzLlWnGugP5WCtnHKkJWoKZBqO2RfOBCq+hY4sxvn3BHVbXqGcXLnZPvo
YuaK7tTXxZSoYLEzeQJBAL8Mt3AkF1Gci5HOug6jT4s4Z+qDDrUXo9BlTwSWP90v
wlHF+mkTJpKd5Wacef0vV+xumqNorvLpIXWKwxNaoHM=
-----END RSA PRIVATE KEY-----'
const priv = forge.pki.privateKeyFromPem(private_key);
const pub = forge.pki.publicKeyFromPem(pub_key);
const g_key_l = [0x42, 0xda, 0x13, 0xba, 0x78, 0x76, 0x8d, 0x37, 0xe8, 0xee, 0x04, 0x91]
const g_key_s = [0x29, 0x23, 0x21, 0x5e]
const g_kts = [0xf0, 0xe5, 0x69, 0xae, 0xbf, 0xdc, 0xbf, 0x5a, 0x1a, 0x45, 0xe8, 0xbe, 0x7d, 0xa6, 0x73, 0x88, 0xde, 0x8f, 0xe7, 0xc4, 0x45, 0xda, 0x86, 0x94, 0x9b, 0x69, 0x92, 0x0b, 0x6a, 0xb8, 0xf1, 0x7a, 0x38, 0x06, 0x3c, 0x95, 0x26, 0x6d, 0x2c, 0x56, 0x00, 0x70, 0x56, 0x9c, 0x36, 0x38, 0x62, 0x76, 0x2f, 0x9b, 0x5f, 0x0f, 0xf2, 0xfe, 0xfd, 0x2d, 0x70, 0x9c, 0x86, 0x44, 0x8f, 0x3d, 0x14, 0x27, 0x71, 0x93, 0x8a, 0xe4, 0x0e, 0xc1, 0x48, 0xae, 0xdc, 0x34, 0x7f, 0xcf, 0xfe, 0xb2, 0x7f, 0xf6, 0x55, 0x9a, 0x46, 0xc8, 0xeb, 0x37, 0x77, 0xa4, 0xe0, 0x6b, 0x72, 0x93, 0x7e, 0x51, 0xcb, 0xf1, 0x37, 0xef, 0xad, 0x2a, 0xde, 0xee, 0xf9, 0xc9, 0x39, 0x6b, 0x32, 0xa1, 0xba, 0x35, 0xb1, 0xb8, 0xbe, 0xda, 0x78, 0x73, 0xf8, 0x20, 0xd5, 0x27, 0x04, 0x5a, 0x6f, 0xfd, 0x5e, 0x72, 0x39, 0xcf, 0x3b, 0x9c, 0x2b, 0x57, 0x5c, 0xf9, 0x7c, 0x4b, 0x7b, 0xd2, 0x12, 0x66, 0xcc, 0x77, 0x09, 0xa6]
var m115_l_rnd_key = genRandom(16)
var m115_s_rnd_key = []
var key_s = []
var key_l = []
function intToByte(i) {
var b = i & 0xFF;
var c = 0;
if (b >= 256) {
c = b % 256;
c = -1 * (256 - c);
} else {
c = b;
}
return c
}
function stringToArray(s) {
var map = Array.prototype.map
var array = map.call(s, function (x) {
return x.charCodeAt(0);
})
return array
}
function arrayTostring(array) {
var result = "";
for (var i = 0; i < array.length; ++i) {
result += (String.fromCharCode(array));
}
return result;
}
function m115_init() {
key_s = []
key_l = []
}
function m115_setkey(randkey, sk_len) {
var length = sk_len * (sk_len - 1)
var index = 0
var xorkey = ''
if (randkey) {
for (var i = 0; i < sk_len; i++) {
var x = intToByte((randkey) + (g_kts[index]))
xorkey += String.fromCharCode(g_kts[length] ^ x)
length -= sk_len
index += sk_len
}
if (sk_len == 4) {
key_s = stringToArray(xorkey)
}
else if (sk_len == 12) {
key_l = stringToArray(xorkey)
}
}
}
function xor115_enc(src, key) {
var lkey = key.length
var secret = []
var num = 0
var pad = (src.length) % 4
if (pad > 0) {
for (var i = 0; i < pad; i++) {
secret.push((src) ^ key)
}
src = src.slice(pad)
}
for (var j = 0; j < src.length; j++) {
if (num >= lkey) {
num = num % lkey
}
secret.push((src[j] ^ key[num]))
num += 1
}
return secret
}
function genRandom(len) {
var keys = []
var chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz23456789';
var maxPos = chars.length;
for (var i = 0; i < len; i++) {
keys.push(chars.charAt(Math.floor(Math.random() * maxPos)).charCodeAt(0));
}
return keys;
}
function m115_encode(plaintext) {
console.log('m115_encode:')
m115_init()
key_l = g_key_l
m115_setkey(m115_l_rnd_key, 4)
var tmp = xor115_enc(stringToArray(plaintext), key_s).reverse()
var xortext = xor115_enc(tmp, key_l)
var text = arrayTostring(m115_l_rnd_key) + arrayTostring(xortext)
var ciphertext = pub.encrypt(text)
ciphertext = encodeURIComponent(forge.util.encode64(ciphertext))
return ciphertext
}
function m115_decode(ciphertext) {
console.log('m115_decode:')
var bciphertext = forge.util.decode64(ciphertext)
var block = bciphertext.length / (128)
var plaintext = ''
var index = 0
for (var i = 1; i <= block; ++i) {
plaintext += priv.decrypt(bciphertext.slice(index, i * 128))
index += 128
}
m115_s_rnd_key = stringToArray(plaintext.slice(0, 16))
plaintext = plaintext.slice(16);
m115_setkey(m115_l_rnd_key, 4)
m115_setkey(m115_s_rnd_key, 12)
var tmp = xor115_enc(stringToArray(plaintext), key_l).reverse()
plaintext = xor115_enc(tmp, key_s)
return arrayTostring(plaintext)
}
//#endregion
function hereDoc(f) {
return f.toString().replace(/^[^/]+/*!?s?/, '').replace(/*/[^/]+$/, '');
}
var getTamplateLines = function () {
/*
<div style="height:120px;">
<div style="text-align: left;font-style: italic;font-size: medium;overflow-x: hidden;overflow-y: auto;margin: 10px 10px;">
<p id="sha1Item" ></p>
</div>
</div>
*/
}
//post from iframe
function postSha1Messgae(id, fileName) {
var dataInfo = '';
if (id == -1) {//begin
dataInfo = { id: -1 };
}
else if (id == 0) {//item
dataInfo = { id: 0, fileName: fileName };
}
else {//end
dataInfo = { id: 1 };
}
var text = JSON.stringify(dataInfo);
window.parent.postMessage(text, "*");
}
//解决提取时的alert不能全屏的问题
if (window.top === window.self) {
$(function () {
var $sha1Item = null;
var getTamplate = hereDoc(getTamplateLines);
$(window).on("message", function (e) {
var data = JSON.parse(e.originalEvent.data);
console.log(data);
if (data.id == 0) {
if ($sha1Item) {
$sha1Item.html(data.fileName);
}
}
else if (data.id == -1) {
Swal.fire({
title: '正在获取文件sha1,请稍后...',
html: getTamplate,
allowOutsideClick: false,
onBeforeOpen: function () {
Swal.showLoading();
var $swalContent1 = $(Swal.getContent());
$sha1Item = $swalContent1.find("#sha1Item");
}
})
}
else {
Swal.close();
}
})
});
}
var str = document.URL;
var hProtocol = "115://";
var store_folder = "store_folder";
var store_folder_default = "云下载";
var store_cid = "store_cid";
GM_setValue(store_cid, "0");
GM_setValue(store_folder, store_folder_default);
var uploadinfo = null;
waitForKeyElements("div.file-opr", AddShareSHA1Btn);
waitForKeyElements("div.dialog-bottom", AddDownloadSha1Btn);
//20200922消失的转存按钮
//20201103优化代码
var p_zhuancun = '<a href="javascript:;" class="button btn-line btn-upload" menu="offline_task"><i class="icon-operate ifo-linktask"></i><span>链接任务</span><em style="display:none;" class="num-dot"></em></a>';
$(".left-tvf").eq(0).append(p_zhuancun);
window.linkText = ""
window.reqcount = 0
window.cookie = document.cookie
function getUploadInfo(resultFunction) {
$.ajax({
dataType: "json",
url: "https://proapi.115.com/app/uploadinfo",
success: function (data) {
resultFunction(data);
}
});
}
function delay(ms) {
if (ms == 0) {
ms = 1000 * (Math.floor(Math.random() * (11 - 4)) + 4);
console.log(ms);
}
return new Promise(resolve => setTimeout(resolve, ms))
}
function download(filename, content, contentType) {
if (!contentType) contentType = 'application/octet-stream';
var a = document.createElement('a');
var blob = new Blob([content], { 'type': contentType });
a.href = window.URL.createObjectURL(blob);
a.download = filename;
a.click();
}
function SetListView() {
GM_xmlhttpRequest({
method: "POST",
url: 'https://115.com/?ct=user_setting&ac=set',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
data: PostData({
setting: '{"view_file":"list"}'
}),
responseType: 'json',
onload: function (response) {
if (response.status === 200) {
}
}
});
}
function AddStroeFloder() {
GM_xmlhttpRequest({
method: "POST",
url: 'https://webapi.115.com/files/add',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
data: PostData({
pid: '0',
cname: StoreFolder
}),
responseType: 'json',
onload: function (response) {
if (response.status === 200) {
}
}
});
}
function Init() {
//FormatCookieString();
var cid = 0;
var info = '';
GM_xmlhttpRequest({
method: "GET",
//url: 'https://webapi.115.com/files?aid=1&cid=0&o=user_ptime&asc=0&offset=0&show_dir=1&limit=115&code=&scid=&snap=0&natsort=1&record_open_time=1&source=&format=json',
url: 'https://aps.115.com/natsort/files.php?aid=1&cid=0&o=file_name&asc=1&offset=0&show_dir=1&limit=115&code=&scid=&snap=0&natsort=1&record_open_time=1&source=&format=json&fc_mix=0',
responseType: 'json',
onload: function (response) {
if (response.status === 200) {
info = response.response;
console.log("............init");
info.data.forEach(function (line) {
//保存默认cid
if (line.n == GM_getValue(store_folder)) {
GM_setValue(store_cid, line.cid);
console.log("init cid:" + line.cid);
}
})
}
}
});
}
Init();
function PostData(dict) {
var k, tmp, v;
tmp = [];
for (k in dict) {
v = dict[k];
tmp.push(k + "=" + v);
}
return tmp.join('&');
};
function UrlData(dict) {
var k, tmp, v;
tmp = [];
for (k in dict) {
v = dict[k];
tmp.push((encodeURIComponent(k)) + "=" + (encodeURIComponent(v)));
}
return tmp.join('&');
};
function GetSig(userid, fileid, target, userkey) {
var sha1, tmp;
sha1 = new jsSHA('SHA-1', 'TEXT');
sha1.update("" + userid + fileid + fileid + target + "0");
tmp = sha1.getHash('HEX');
sha1 = new jsSHA('SHA-1', 'TEXT');
sha1.update("" + userkey + tmp + "000000");
return sha1.getHash('HEX', {
outputUpper: true
});
}
async function test(info, flag) {
window.linkText = ""
if (info[0].indexOf('|') == -1) {
GetFilesByCID(info[0]);
await delay(3000);
while (window.reqcount != 0) {
await delay(50);
}
postSha1Messgae(1, "");
download(info[1] + "_sha1.txt", window.linkText);
return;
}
GetShareLink(info, flag);
}
function DeleteCookie(resp) {
try {
var reg = /set-cookie: .+;/g;
var setcookie = reg.exec(resp)[0].split(';');
var filecookie = setcookie[0].slice(11) + "; expires=Thu, 01 Jan 1970 00:00:00 UTC;" + setcookie[3] + ";domain=.115.com";
document.cookie = filecookie;
RenewCookie()
return filecookie;
}
catch (err) {
return null;
}
}
function RenewCookie() {
var arryCookie = window.cookie.split(';');
arryCookie.forEach(function (kv) {
document.cookie = kv + ";expires=Thu, 01 Jan 2100 00:00:00 UTC;;domain=.115.com"
}
)
}
function GetFilesByCID(cid) {
GM_xmlhttpRequest({
method: "GET",
url: "https://webapi.115.com/files?aid=1&cid=" + cid + "&o=user_ptime&asc=0&offset=0&show_dir=1&limit=1150&code=&scid=&snap=0&natsort=1&record_open_time=1&source=&format=json&type=&star=&is_share=&suffix=&custom_order=&fc_mix=",
responseType: 'json',
onload: function (response) {
if (response.status === 200) {
var info = response.response;
try {
info.data.forEach(function (line) {
if (line.cid != cid) //folder
{
GetFilesByCID(line.cid);
}
else {
GetShareLink([line.n + '|' + line.s + '|' + line.sha, line.pc, line.fid], false);
}
}
)
}
catch (err) {
GM_xmlhttpRequest({
method: "GET",
url: "https://aps.115.com/natsort/files.php?aid=1&cid=" + cid + "&o=file_name&asc=1&offset=0&show_dir=1&limit=1150&code=&scid=&snap=0&natsort=1&record_open_time=1&source=&format=json&type=&star=&is_share=&suffix=&custom_order=&fc_mix=0", responseType: 'json',
onload: function (response) {
if (response.status === 200) {
var info = response.response;
try {
info.data.forEach(function (line) {
if (line.cid != cid) //folder
{
GetFilesByCID(line.cid);
}
else {
GetShareLink([line.n + '|' + line.s + '|' + line.sha, line.pc, line.fid], false);
}
}
)
}
catch (err) {
alert(err);
}
}
}
});
}
}
}
});
}
function CreateShareLink(url, info, cookie, flag) {
var pre_buff = null;
if (url !== undefined) {
GM_xmlhttpRequest({
method: "GET",
url: url,
headers: {
"Range": "bytes=0-154112",
"Cookie": cookie
},
responseType: 'arraybuffer',
onload: function (response, shalink) {
if (response.status === 206) {
window.reqcount -= 1
pre_buff = response.response;
try {
var data = new Uint8Array(pre_buff);
var sha1 = new jsSHA('SHA-1', 'ARRAYBUFFER');
sha1.update(data.slice(0, 128 * 1024));
var preid = sha1.getHash('HEX', {
outputUpper: true
});
var aLink = hProtocol + info[0] + '|' + preid;
console.log(aLink);
window.linkText += aLink + 'n'
postSha1Messgae(0, aLink);
if (flag) {
postSha1Messgae(1, "");
setTimeout(() => { prompt("复制分享链接到剪贴板", hProtocol + info[0] + '|' + preid); }, 500);
}
}
catch (err) { alert(err); }
} else {
window.reqcount -= 1
return GM_log("response.status = " + response.status);
}
}
});
}
}
function GetShareLink(info, flag) {
var download_info = null;
GM_xmlhttpRequest({
method: "POST",
url: 'http://proapi.115.com/app/chrome/downurl',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
responseType: 'json',
data: PostData({ data: m115_encode('{"pickcode":"' + info[1] + '"}') }),
onload: function (response) {
if (response.status === 200) {
download_info = response.response;
console.log(download_info);
var json = m115_decode(download_info.data);
var url = JSON.parse(json)[info[2]]['url']['url'];
window.reqcount += 1
var resp = response.responseHeaders
var setcookie = DeleteCookie(resp)
var filecookie = null;
if (setcookie) {
filecookie = setcookie;
}
postSha1Messgae(0, "文件名: " + info[0].split('|')[0]);
CreateShareLink(url, info, filecookie, flag);
} else {
return GM_log("response.status = " + response.status);
}
}
});
}
var tamplateLines = function () {
/*
<div style="height:320px;">
<div style="display: flex;font-size: xx-large;margin: 10px 0;">
<div style="color:black;display: flex;">
<p>总共:</p>
<p id="totalCount"></p>
<p>,</p>
</div>
<div style="color: green;display: flex;">
<p>成功:</p>
<p id="succeedCount"></p>
<p>,</p>
</div>
<div style="color: red;display: flex;">
<p>失败:</p>
<p id="failedCount"></p>
</div>
</div>
<div class="itemContent" style="text-align: left;font-style: italic; margin: 10px 0;">
</div>
<hr />
<div style="height:240px;overflow-x: hidden;overflow-y: auto;">
<ul class="errorList" style="font-size: medium;text-align: left;"></ul>
</div>
</div>
*/
};
//todo: 此处增加进度条提示
function NewDownloadFileFromSha1Links(links) {
if (links == "") {
alert("链接不能为空");
return;
}
var storecid = GM_getValue(store_cid);
console.log("*stroe_cid " + storecid);
var target = 'U_1_' + storecid;
//去除空行
var allTampLinks = links.split(/r?n/);
var allLinks = new Array();
for (var j = 0; j < allTampLinks.length; j++) {
var l = allTampLinks[j].trim();
if (l != "") {
allLinks.push(l);
}
}
console.log('sha1 links count : ' + allLinks.length);
if (allLinks.length == 0) return;
var $swalContent = null;
var $totalCount = null;
var $succeedCount = null;
var $failedCount = null;
var $errorList = null;
var $itemContent = null
var template = hereDoc(tamplateLines);
Swal.fire({
title: '正在转存文件,请稍后...',
html: template,
allowOutsideClick: false,
onBeforeOpen: function () {
Swal.showLoading();
$swalContent = $(Swal.getContent());
$totalCount = $swalContent.find("#totalCount");
$succeedCount = $swalContent.find("#succeedCount");
$failedCount = $swalContent.find("#failedCount");
$errorList = $swalContent.find(".errorList");
$itemContent = $swalContent.find(".itemContent");
}
})
uploadinfo = null;
var errors = new Array();
var sCount = 0;
var sendCount = 0;
var receivedCount = 0;
getUploadInfo(function (data) {
uploadinfo = data;
console.log(uploadinfo);
$totalCount.html(allLinks.length);
var callback = function (res) {
receivedCount = receivedCount + 1;
sCount = sCount + 1;
var htmlText = '<p>' + res.filename + ' ,转存成功!</p>';
if (!res.upload) {
sCount = sCount - 1;
errors.push(res.sha1);
htmlText = '<p style="color: red;">' + res.filename + ' ,转存失败!' + '</p>';
$errorList.append('<li><div display: flex;"><p>' + res.filename + ' , ' + '</p><p style="font-style: italic;">[原因] ' + res.msg + '<p><div><li><li><hr/></li>');
}
$itemContent.html(htmlText);
$succeedCount.html(sCount);
$failedCount.html(errors.length);
};
var lastCallback = function (res) {
callback(res);
//统计出错?
$succeedCount.html(allLinks.length - errors.length);
$itemContent.html("<p>p.s:本工具未去重。</p>");
var outHtml = "";
if (errors.length != 0) {
var text = errors.join("rn");
GM_setClipboard(text);
$itemContent.html("<p>p.s:本工具未去重。已经将失败sha1链接复制到剪贴板!</p>");
}
outHtml = $swalContent[0];
GM_log("allLinks: " + allLinks.length + " , sendCount: " + sendCount + " ,receivedCount: " + receivedCount);
setTimeout(function () {
Swal.fire({
title: '操作完成!',
showCloseButton: true,
allowOutsideClick: false,
html: outHtml
})
}, 350);
}
for (var index = 0; index < allLinks.length; index++) {
var thisIndex = index;
var fLine = allLinks[thisIndex];
if (index == allLinks.length - 1) {
setTimeout(function (target1, fLine1, lastCallback1) {
DownloadFromSha1(target1, fLine1, lastCallback1);
sendCount = sendCount + 1;
}, 160 * (thisIndex + 1), target, fLine, lastCallback)
}
else {
setTimeout(function (target1, fLine1, callback1) {
DownloadFromSha1(target1, fLine1, callback1);
sendCount = sendCount + 1;
}, 160 * (thisIndex + 1), target, fLine, callback)
}
}
})
}
function DownloadFromSha1(targetFolder, sha1Link, resultCallback) {
var nsf = sha1Link.split('|');
//去掉"115://"
if (nsf[0].substring(0, 6) == hProtocol) {
nsf[0] = nsf[0].substring(6);
}
// 文件名,长度,sha1,sha1
//todo: 可能要做检测
if (nsf[0] != '' && nsf[1] != '' && nsf[2] != '' && nsf[3] != '' && nsf[2].length == 40 && nsf[3].length == 40) {
var urlData = UrlData({
isp: 0,
appid: 0,
appversion: '25.2.0',
format: 'json',
sig: GetSig(uploadinfo.user_id, nsf[2], targetFolder, uploadinfo.userkey)
});
var postData = PostData({
preid: nsf[3],
fileid: nsf[2],
quickid: nsf[2],
app_ver: '25.2.0',
filename: nsf[0],
filesize: nsf[1],
exif: '',
target: targetFolder,
userid: uploadinfo.user_id
});
GM_xmlhttpRequest({
method: 'POST',
url: 'http://uplb.115.com/3.0/initupload.php?' + urlData,
data: postData,
responseType: 'json',
headers: {
'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
},
onload: function (response) {
var info = {
"filename": nsf[0],
"sha1": sha1Link,
"upload": true,
"msg": ""
};
if (response.status === 200 && response.response.status === 2) {
resultCallback(info);
}
else {
info.upload = false;
info.msg = response.response.statusmsg;
if (info.msg == "") {
info.msg = "未知,服务器未返回具体原因";
}
console.log(sha1Link + ",转存失败,原因: " + info.msg);
resultCallback(info);
}
}
});
}
else {
var info = {
"filename": nsf[0],
"sha1": sha1Link,
"upload": false,
"msg": "未操作,检测到链接不符合,检查sha1链接或用其他软件"
};
}
}
function GetSha1LinkByliNode(liNode) {
var type = (liNode.getAttribute("file_type"));
var filename = liNode.getAttribute('title');
var fid = "";
if (type == "0") {
fid = liNode.getAttribute('cate_id');
return [fid, filename];
}
else {
var filesize = liNode.getAttribute('file_size');
var sha1 = liNode.getAttribute('sha1');
var pickcode = liNode.getAttribute('pick_code');
fid = liNode.getAttribute('file_id');
return [filename + '|' + filesize + '|' + sha1, pickcode, fid];
}
}
function AddDownloadSha1Btn(jNode) {
var cid_new_0 = $("em[rel=offlint_path_text]").attr("cid");
var name_new_0 = $("em[rel=offlint_path_text]").html();
console.log("cid: " + cid_new_0 + " folder: " + name_new_0);
var cid_old_0 = GM_getValue(store_cid);
var name_old_0 = GM_getValue(store_folder);
if ((cid_new_0 == cid_old_0) && (name_new_0 != name_old_0)) {
$("em[rel=offlint_path_text]").html(name_old_0);
}
if (cid_new_0 == "" && name_new_0 == store_folder_default && name_old_0 == store_folder_default) {
//初始没带cid
$("em[rel=offlint_path_text]").attr("cid", cid_old_0);
}
if (document.getElementById('downsha1') == null) {
var id = document.createElement('div');
id.setAttribute('class', 'con');
id.setAttribute('id', 'downsha1');
var ia = document.createElement('a');
ia.setAttribute('class', 'button');
ia.setAttribute('href', 'javascript:;');
var inode = document.createTextNode("使用 sha1 链接转存");
ia.appendChild(inode);
id.appendChild(ia);
jNode[0].appendChild(id);
id.addEventListener('click', function (e) {
var links = document.getElementById('js_offline_new_add').value;
//获取保存的位置:
cid_new_0 = $("em[rel=offlint_path_text]").attr("cid");
name_new_0 = $("em[rel=offlint_path_text]").html();
console.log("close cid: " + cid_new_0 + " folder: " + name_new_0);
GM_setValue(store_folder, name_new_0);
if (cid_new_0 != "") {
GM_setValue(store_cid, cid_new_0);
}
(document.getElementsByClassName('close')[2].click());
NewDownloadFileFromSha1Links(links);
})
}
}
function AddShareSHA1Btn(jNode) {
var parentNode = jNode[0].parentNode;
var sha1Link = GetSha1LinkByliNode(parentNode);
var aclass = document.createElement('a');
aclass.addEventListener('click', function (e) {
postSha1Messgae(-1, "");
test(sha1Link, true);
})
var iclass = document.createElement('i');
var ispan = document.createElement('span');
var node = document.createTextNode("获取 SHA1 链接");
ispan.appendChild(node);
aclass.appendChild(iclass);
aclass.appendChild(ispan);
jNode[0].appendChild(aclass);
}
})();
[/content_hide]
浏览器跟油猴下载地址已分享
此隐藏内容仅限VIP查看升级VIP