// ==UserScript==
// @name Bangumi Tookit
// @namespace http://weibo.com/zheung
// @version 1.0.7
// @description Bangumi Tookit 没有L!
// @author DanoR
// @match http://bgm.tv/*
// @match http://bangumi.tv/*
// @require http://code.jquery.com/jquery-2.1.4.min.js
// @run-at document-end
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_addStyle
// @downloadURL none
// ==/UserScript==
/* global btkConfig */
///
try{
console.log('Bangumi Tookit v1.0.7 started');
var useScriptDB = true; //脚本数据开关, false则使用下面的configManual作为每次打开网页的配置,功能一样,BTK的管理功能不会存储修改后的配置
var configManual = {
"trans":true,
"search":true,
"sort":true,
"shift":-1,
"maxWidth":"520px",
"searchs":{
"dmhy":{
"display1":"dmhy",
"display2":"动漫花园",
"url":"http://share.dmhy.org/topics/list?keyword=%key"
},
"bili":{
"display1":"bili",
"display2":"哔哩哔哩",
"url":"http://www.bilibili.com/search?keyword=%key"
},
"sohu":{
"display1":"sohu",
"display2":"搜狐专题",
"url":"http://tv.sohu.com/%key"
},
"pptv":{
"display1":"pptv",
"display2":"聚力专题",
"url":"http://www.pptv.com/page/%key.html"
},
"iqyi":{
"display1":"iqyi",
"display2":"奇艺专题",
"url":"http://www.iqiyi.com/%key.html"
}
},
"dicts":{
"975":{
"trans":"海贼王",
"searchs":{
"dmhy":"海賊王",
"sohu":"s2013/onepiece"
},
"shift":0
},
"43523":{
"trans":"美少女战士 Crystal",
"searchs":{
"dmhy":"少女 Crystal"
}
},
"91946":{
"trans":"妖精的尾巴 第二期",
"searchs":{
"sohu":"s2011/yjdwb"
}
},
"104906":{
"trans":"境界触发者",
"searchs":{
"iqyi":"a_19rrhc0zzx"
}
},
"105075":{
"trans":"血界战线",
"searchs":{
"dmhy":"血界"
}
},
"113906":{
"trans":"网球优等生 第二季",
"searchs":{
"iqyi":"a_19rrhaybvd"
}
},
"116461":{
"trans":"食戟之灵",
"searchs":{
"dmhy":"之靈"
}
},
"116716":{
"trans":"圣斗士星矢 黄金魂",
"searchs":{
"dmhy":"星矢 金"
}
},
"116871":{
"trans":"亚尔斯兰战记",
"searchs":{
"dmhy":"蘭戰|Arslan"
}
},
"117153":{
"trans":"俺物语!!",
"searchs":{
"dmhy":"俺物"
}
},
"117731":{
"trans":"境界的轮回",
"searchs":{
"dmhy":"境界 輪"
}
},
"122606":{
"trans":"电波教师",
"searchs":{
"dmhy":"波教"
}
}
}
};
//加载配置
// var btkConfig;
function initConfig() {
if(useScriptDB)
{
btkConfig = GM_getValue('btk-config');
if(!btkConfig)
btkConfig = {
"trans":true,
"search":true,
"sort":true,
"shift":0,
"maxWidth":"520px",
"search":{},
"dicts":{}
};
else
btkConfig = JSON.parse(btkConfig);
}
else
btkConfig = configManual;
return btkConfig;
}
function saveConfig() {
if(useScriptDB)
GM_setValue('btk-config', JSON.stringify(btkConfig, function(key, value) {
return key!='sorter'?value:undefined;
}));
}
initConfig();
if(location.pathname == '/') { //首页大功能
//加载界面
GM_addStyle(
'.btk-ul>li{ margin:7px; width:100% } \
li>text { margin-left:6px; } \
.btk-ul>li>:nth-child(1){ margin-left:4px; } \
.btk-button:focus{ outline:none; } \
.btk-button{ cursor:pointer; border-radius:4px; padding:4px 5px; margin-left:5px; border:2px solid #F09199; \
-webkit-user-select:none; -moz-user-select:none; } \
.btk-text {cursor:initial; width:45px; margin-left:4px; text-align:center; } \
.btk-text2 {cursor:initial; width:69%; margin-left:4px; } \
.btk-text3 {cursor:initial; width:24%; margin-left:4px; text-align:center; } \
.btk-on{ color:white; background:#F09199; } \
.btk-off{ color:#F09199; background:white; } \
.btk-panel{ text-decoration:none; color:#444; cursor:pointer; } \
.btk-mask { position:absolute; top:40px; left:0; }\
.btk-select { background:red; opacity:0.2; float:left; margin:5px 0 0 5px; \
padding:5px 0 5px 5px; width:340px; position:relative; \
-moz-border-radius:3px;-webkit-border-radius:3px; border-radius:3px; \
-webkit-transition:border linear 0.2s,box-shadow linear 0.3s; \
-moz-transition:border linear 0.1s,box-shadow linear 0.3s; \
transition:border linear 0.1s,box-shadow linear 0.3s; } .btk-select.odd { clear:both } \
.btk-exist { background:green; } \
.btk-border { border:2px solid black; width:99%; height:97%; position:absolute; top:0; left:0; cursor:pointer } \
.btk-border:hover { border:2px solid red; } \
.btk-searcher, .btk-configer { border-top:1px solid gray; } \
.btk-configer>text { line-height:30px; } \
.btk-searcher>text { line-height:30px; } \
.btk-selector { width:74%; }'
);
var panel = $('
').hide();
panel.append($('
')
.append($('
Bangumi Tookit
')).append($('
')));
$('div.sideInner').prepend(panel);
$('div.content>ul.clearit>:nth-child(2)>:nth-child(2)').after($('工具')
.click(function() { panel.slideToggle(); })).after($(document.createTextNode(' | ')));
var toggleFunc = function(which, type) {
var $this = $(which);
if($this.hasClass('btk-on'))
btkConfig[type] = false;
else if($this.hasClass('btk-off'))
btkConfig[type] = true;
$this.toggleClass('btk-on').toggleClass('btk-off');
saveConfig();
refresher[type]();
};
var a1 = $('中日切换').addClass(btkConfig.trans?'btk-on':'btk-off')
.click(function(){ toggleFunc(this, 'trans'); });
var a2 = a1.clone().html('搜索链接').addClass(btkConfig.search?'btk-on':'btk-off')
.removeClass(btkConfig.search?'btk-off':'btk-on').click(function(){ toggleFunc(this, 'search'); });
var a3 = a1.clone().html('播出排序').addClass(btkConfig.sort?'btk-on':'btk-off')
.removeClass(btkConfig.sort?'btk-off':'btk-on').click(function(){ toggleFunc(this, 'sort'); });
var a4 = a1.clone().html('导入配置').addClass('btk-on').removeClass('btk-off').click(function(){
if(confirm('确定要导入! 导入! 导入默认配置吗??\r\n这将会覆盖! 覆盖! 覆盖现有配置!!')) {
btkConfig = configManual;
saveConfig();
refresher.trans();
refresher.search();
refresher.shift();
refresher.sort();
i1.val(btkConfig.shift);
var mask = $('.btk-mask');
if(mask.children().length)
refreshMask();
alert('导入成功');
}
});
//UI-配置条目
function refreshSeacher(seacher, searchs) {
seacher.empty().append($('