Skip to content

Commit

Permalink
查看失效视频又双叒叕回来了
Browse files Browse the repository at this point in the history
  • Loading branch information
imba97 committed Apr 13, 2020
1 parent 3a7f9f7 commit fa4bf51
Show file tree
Hide file tree
Showing 8 changed files with 181 additions and 121 deletions.
7 changes: 6 additions & 1 deletion README.md
Expand Up @@ -7,7 +7,7 @@
[![website](https://img.shields.io/website-up-down-green-red/https/shields.io.svg?label=website)](http://btools.cc)

## 前言
如果你想参观代码(屎山),请先看这里。
如果你想参观代码(**屎山**),请先看这里。
代码是纯jQuery项目,没其他框架,没用其他工具,目录结构、文件名、函数名我记几个儿随便瞎起的,所以观赏性极差,劝你做好心理准备。

## 介绍
Expand Down Expand Up @@ -70,6 +70,11 @@ Btools(逼砣),本插件主要目的是以B站为主的网站页面优化,
* 修复历史表情无法出现的BUG
* 修复点击楼中楼历史表情输入到主评论框的BUG
* 现在历史表情可以增加更多的表情
* 修复视频简介超链接只能获取到最后一个的BUG
* `2020-04-13`
* 收藏夹失效视频又双叒叕回来了(兼容BV)
* 优化收藏夹失效视频的获取方式,现在可以一次获取一整页
* 现在视频页面中的“打开封面”按钮会根据播放器的位置而改变

* #### [关于查看失效视频半全恢复说明](https://btools.cc/announcement-2019-11-04/)

Expand Down
1 change: 1 addition & 0 deletions background.html
Expand Up @@ -6,5 +6,6 @@
</head>
<body>
</body>
<script src="js/jq.js"></script>
<script src="background.js"></script>
</html>
44 changes: 16 additions & 28 deletions background.js
Expand Up @@ -7,38 +7,26 @@ var BtoolsInfo = {

// 安装完成后
chrome.runtime.onInstalled.addListener(function(details) {

// 1.1.3 清除本地缓存
chrome.storage.sync.set({
localCache: {}
});
});

chrome.runtime.onMessage.addListener(
function(request, sender, sendResponse) {
switch(request.type) {
case 'fetch':
fetch(request.url)
.then(function(response) { return response.json() })
.then(function(json) { return sendResponse(json) })
.catch(function(error) { return sendResponse(null) });
return true; // Will respond asynchronously.
break;
case 'post':
fetch(request.url, {
method: 'POST',
mode: 'cors',
credentials: 'include',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: JSON.stringify(request.data)
})
.then(function(response) { return response.json() })
.then(function(json) { return sendResponse(json) })
.catch(function(error) { return sendResponse(null) });
return true; // Will respond asynchronously.
break;
case 'getInfo':
sendResponse(BtoolsInfo);
break;
}
switch(request.type) {
case 'fetch':
fetch(request.url)
.then(function(response) { return response.json() })
.then(function(json) { return sendResponse(json) })
.catch(function(error) { return sendResponse(null) });
return true; // Will respond asynchronously.
break;
case 'getInfo':
sendResponse(BtoolsInfo);
break;
}
});

/*
Expand Down
60 changes: 52 additions & 8 deletions core/Btools.js
Expand Up @@ -23,31 +23,75 @@ var Btools = {
}
}

var avbv = {
table: 'fZodR9XQDSUm21yCkr6zBqiveYah8bt4xsWpHnJE7jL5VG3guMTKNPAwcF',
xor: 177451812,
add: 8728348608,
s: [11, 10, 3, 8, 4, 6]
}

// BV2AV - 参考 http://bv2av.com/
function bv2av(bv) {

var table = 'fZodR9XQDSUm21yCkr6zBqiveYah8bt4xsWpHnJE7jL5VG3guMTKNPAwcF';
var s = [11, 10, 3, 8, 4, 6];

var xor = 177451812;
var add = 8728348608;

var result = 0;
for(var i = 0; i < 6; i++) {
result += table.indexOf(bv[s[i]]) * 58 ** i;
result += avbv.table.indexOf(bv[avbv.s[i]]) * Math.pow(58, i);
}

var av = (result - add ^ xor);
var av = (result - avbv.add ^ avbv.xor);

return av;
}

function av2bv(av) {
av = (av ^ avbv.xor) + avbv.add;
var result = ['B', 'V', '1', ' ', ' ', '4', ' ', '1', ' ', '7', ' ', ' '];
for(var i = 0; i < 6; i++) {
result[avbv.s[i]] = avbv.table[Math.floor(av / Math.pow(58, i)) % 58];
}
return result.join('');
}

chrome.runtime.sendMessage({ type: 'getInfo' }, function(info) {
Btools.version = info.version;
Btools.releaseVersion = info.releaseVersion;
Btools.info = '%c ____ __ ___\n/\\ _`\\ /\\ \\__ /\\_ \\\n\\ \\ \\L\\ \\\\ \\ ,_\\ ___ ___\\//\\ \\ ____\n \\ \\ _ <\'\\ \\ \\/ / __`\\ / __`\\\\ \\ \\ /\',__\\\n \\ \\ \\L\\ \\\\ \\ \\_/\\ \\L\\ \\/\\ \\L\\ \\\\_\\ \\_/\\__, `\\ \n \\ \\____/ \\ \\__\\ \\____/\\ \\____//\\____\\/\\____/\n \\/___/ \\/__/\\/___/ \\/___/ \\/____/\\/___/\n\n version ' + info.version;
});

/*
var getCookie = function (NameOfCookie) {
if (document.cookie.length > 0) {
begin = document.cookie.indexOf(NameOfCookie + "=");
if (begin !== -1) {
begin += NameOfCookie.length + 1;
end = document.cookie.indexOf(";", begin);
if (end === -1) end = document.cookie.length;
return unescape(document.cookie.substring(begin, end));
}
}
return null;
}
*/

/*
$.ajax({
type: 'POST',
url: 'https://api.bilibili.com/x/web-interface/archive/like',
data: {
aid: 882653974,
like: 1,
csrf: getCookie('bili_jct')
},
success: function(json) {
return console.log(json)
},
error: function(error) {
return console.log(error)
},
dataType: 'json'
});
*/

// 监听加载状态改变
document.onreadystatechange = function() {
if (document.readyState === 'complete') {
Expand Down
10 changes: 10 additions & 0 deletions core/openImg/m.js
Expand Up @@ -59,6 +59,16 @@ openImgSet.timer = setInterval(function(){
]);
}

$(window).resize(function() {
var bofqiTop = $('#bofqi').offset().top + 22;
var bofqiLeft = $('#bofqi').offset().left - 40;
console.log(bofqiTop);
$('.BtoolsLogoBtn').css({
'top': bofqiTop,
'left': bofqiLeft
});
});

clearInterval(openImgSet.timer);

// 直播封面获取
Expand Down

0 comments on commit fa4bf51

Please sign in to comment.