Skip to content

Commit

Permalink
fix root fold
Browse files Browse the repository at this point in the history
  • Loading branch information
acgotaku committed Jan 10, 2015
1 parent 490d789 commit 47057fe
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 22 deletions.
28 changes: 18 additions & 10 deletions chrome/js/baidu.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
// @include https://*n.baidu.com/disk/home*
// @include https://*n.baidu.com/share/link*
// @run-at document-end
// @version 0.2.9
// @version 0.3.0
// ==/UserScript==
var baidu = function(cookies) {
var version = "0.2.9";
var update_date = "2015/01/10";
var version = "0.3.0";
var update_date = "2015/01/11";
var baidupan = (function() {
var home = window.location.href.indexOf("/disk/home") != -1 ? true : false;
//封装的百度的Toast提示消息
Expand Down Expand Up @@ -215,9 +215,10 @@ var baidu = function(cookies) {
var length = Filename.length;
for (var i = 0; i < length; i++) {
if (obj.dlink[0].fs_id == Filename[i].attr("data-id")) {
name = name+ Filename[i].children().eq(0).children().eq(2).attr("title")||Filename[i].children().eq(0).attr("title");
var temp =Filename[i].children().eq(0).children().eq(2).attr("title")||Filename[i].children().eq(1).children().eq(0).attr("title");
name =name +temp;
}
}
}//Filename[0].children().eq(1).children().eq(0).attr("title")

file_list.push({"name": name, "link": obj.dlink[0].dlink});
self[func](file_list);
Expand All @@ -226,23 +227,30 @@ var baidu = function(cookies) {
get_level:function(){
var API = (require("common:widget/restApi/restApi.js"),require("common:widget/hash/hash.js"));
var level=parseInt($("#rpc_fold").val());
var path="";
var maxlevel=API.get("path").split("/").length-1;
var path=API.get("path");
var maxlevel=0;
if(path == "/"|| path == null){
path="";
}else{
maxlevel=path.split("/").length-1;
}
if(level>maxlevel){
SetMessage("文件夹层数超过完整路径", "MODE_CAUTION");
level=maxlevel;
}
if(level == -1){
path=API.get("path")+"/";
path=path+"/";
}else if(level>0){
var num=[];
for(var i=0;i<level;i++){
num.push(".*");
}
var re = new RegExp(".*\/("+num.join("\/")+")$");
console.log(API.get("path").match(re));
path=API.get("path").match(re)[1]+"/";
path=path.match(re)[1]+"/";
}else if(level==0){
path="";
}
console.log(path);
return path;
},
//获取文件夹下载的信息
Expand Down
2 changes: 1 addition & 1 deletion chrome/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
"manifest_version": 2,
"permissions": [ "cookies", "tabs", "*://*.baidu.com/*"],
"name": "__MSG_appName__",
"version": "0.2.9"
"version": "0.3.0"
}
Binary file modified firefox/baidu-exporter.xpi
Binary file not shown.
28 changes: 18 additions & 10 deletions firefox/data/js/baidu.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
// @include https://*n.baidu.com/disk/home*
// @include https://*n.baidu.com/share/link*
// @run-at document-end
// @version 0.2.9
// @version 0.3.0
// ==/UserScript==
var baidu = function(cookies) {
var version = "0.2.9";
var update_date = "2015/01/10";
var version = "0.3.0";
var update_date = "2015/01/11";
var baidupan = (function() {
var home = window.location.href.indexOf("/disk/home") != -1 ? true : false;
//封装的百度的Toast提示消息
Expand Down Expand Up @@ -215,9 +215,10 @@ var baidu = function(cookies) {
var length = Filename.length;
for (var i = 0; i < length; i++) {
if (obj.dlink[0].fs_id == Filename[i].attr("data-id")) {
name = name+ Filename[i].children().eq(0).children().eq(2).attr("title")||Filename[i].children().eq(0).attr("title");
var temp =Filename[i].children().eq(0).children().eq(2).attr("title")||Filename[i].children().eq(1).children().eq(0).attr("title");
name =name +temp;
}
}
}//Filename[0].children().eq(1).children().eq(0).attr("title")

file_list.push({"name": name, "link": obj.dlink[0].dlink});
self[func](file_list);
Expand All @@ -226,23 +227,30 @@ var baidu = function(cookies) {
get_level:function(){
var API = (require("common:widget/restApi/restApi.js"),require("common:widget/hash/hash.js"));
var level=parseInt($("#rpc_fold").val());
var path="";
var maxlevel=API.get("path").split("/").length-1;
var path=API.get("path");
var maxlevel=0;
if(path == "/"|| path == null){
path="";
}else{
maxlevel=path.split("/").length-1;
}
if(level>maxlevel){
SetMessage("文件夹层数超过完整路径", "MODE_CAUTION");
level=maxlevel;
}
if(level == -1){
path=API.get("path")+"/";
path=path+"/";
}else if(level>0){
var num=[];
for(var i=0;i<level;i++){
num.push(".*");
}
var re = new RegExp(".*\/("+num.join("\/")+")$");
console.log(API.get("path").match(re));
path=API.get("path").match(re)[1]+"/";
path=path.match(re)[1]+"/";
}else if(level==0){
path="";
}
console.log(path);
return path;
},
//获取文件夹下载的信息
Expand Down
2 changes: 1 addition & 1 deletion firefox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"icon":"data/img/logo64.png",
"icon64":"data/img/logo64.png",
"license": "MPL 2.0",
"version": "0.2.9"
"version": "0.3.0"
}

0 comments on commit 47057fe

Please sign in to comment.