Skip to content
This repository has been archived by the owner on Jan 1, 2020. It is now read-only.

Commit

Permalink
直播设置新增应援团相关内容 重新实现LiveToast
Browse files Browse the repository at this point in the history
  • Loading branch information
MoeHero committed May 4, 2017
1 parent 502c4eb commit 29ac981
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 28 deletions.
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@

## Update Log
`新增` 直播设置支持更多选项
`优化` 取消检测其他插件机制
`优化` 通知图标显示图标多样化
`优化` 自动领取瓜子后瓜子数量动态更新
`修复` 自动领瓜子一直显示领取中的问题
`优化` 自动签到仅在一个直播间开启
`优化` 无法赠送礼物包裹内物品时显示提示
`修复` B站改版导致部分直播页面错位的问题

## TODO List
### 计划功能
Expand All @@ -34,7 +33,7 @@
## Develop Progress
- 重构礼物包裹代码 0%
- 重构直播设置代码 0%
- 优化程序结构 20%
- 优化程序结构 40%
- 重构设置页面 0%
- 自动更新 0%

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "bilibili-helper",
"description": "Bilibili助手",
"version": "0.0.11",
"version": "0.0.12",
"author": "MoeHero",
"license": "MPL-2.0",
"homepage": "https://github.com/MoeHero/BilibiliHelper#readme",
Expand Down
39 changes: 25 additions & 14 deletions src/bilibili_live/FuncGiftPackage.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,32 @@ class FuncGiftPackage {
Live.getMessage((request) => {
if(request.command && request.command == 'sendGiftCallback') {
let result = request.result;
if(result.code === 0) {
if(result.data.remain === 0) {
this.currentGift.element.remove();
this.sendPanel.hide();
} else {
this.sendPanelInfo.text(`您的包裹中还剩 ${result.data.remain} 个可用`);
if(this.sendPanelCount.val() > result.data.remain) {
this.sendPanelCount.val(result.data.remain);
switch(result.code) {
case 0:
if(result.data.remain === 0) {
this.currentGift.element.remove();
this.sendPanel.hide();
} else {
this.sendPanelInfo.text(`您的包裹中还剩 ${result.data.remain} 个可用`);
if(this.sendPanelCount.val() > result.data.remain) {
this.sendPanelCount.val(result.data.remain);
}
this.currentGift.element.find('.gift-count').text('x' + result.data.remain);
this.currentGift.count = result.data.remain;
}
this.currentGift.element.find('.gift-count').text('x' + result.data.remain);
this.currentGift.count = result.data.remain;
}
} else if(result.code == 200005) { //无法给自己赠送道具
} else {
console.log(result);
break;
case -400: //应援棒提示
Live.liveToast('只有在入围偶像活动的主播房间才能赠送该道具!', this.sendPanelButton, 'caution');
break;
case 200005: //无法给自己赠送道具
Live.liveToast('无法给自己赠送道具!', this.sendPanelButton, 'caution');
break;
case 1024: //超时
Live.liveToast('赠送礼物超时, 请稍后再试!', this.sendPanelButton, 'error');
break;
default:
console.log(result);
break;
}
this.sendPanelCount.focus();
}
Expand Down
9 changes: 8 additions & 1 deletion src/bilibili_live/FuncLiveSetting.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class FuncLiveSetting {
vip: {name: '老爷进场', click: this.vip_click, state: true},
sysmsg: {name: '系统公告', click: this.sysmsg_click, state: true},
tvmsg: {name: '小电视公告', click: this.tvmsg_click, state: true},
link: {name: '应援团相关内容', click: this.link_click, state: true},
'show-admin': {name: '显示房管列表', click: this.show_admin_click, state: false},
'super-gift': {name: '礼物连击', click: this.super_gift_click, state: true}
};
Expand Down Expand Up @@ -87,9 +88,15 @@ class FuncLiveSetting {
static super_gift_click() {
$('#super-gift-ctnr-haruna').toggleClass('hide');
}
static link_click() {
if(this.funcList['link'].state) {
this.link_css = Live.addStylesheetByText('.bilibili-link{display:none!important;}');
} else {
this.link_css.remove();
}
}

static chatListScrollToBottom() {
$('#chat-msg-list').scrollTop($('#chat-msg-list')[0].scrollHeight);
}
}
/**/
20 changes: 20 additions & 0 deletions src/bilibili_live/Live.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ Live.addStylesheetByText = function(text) {
return style;
};

Live.liveToast = (message, element, type = 'info') => {
//success caution error info
let newToast = $('<div>').addClass('live-toast ' + type)
.append($('<i>').addClass('toast-icon ' + type), $('<span>').addClass('toast-text').text(message))
.css({'left': $.getLeft(element[0]) + element.width()})
.css({'top': $.getTop(element[0]) + element.height()});
$('body').append(newToast);
Live.countdown(2, () => newToast.fadeOut(200));
};

Live.getRoomID = function(showID, callback) {
let rid = ModuleStore.roomID_get(showID);
if(!rid) {
Expand Down Expand Up @@ -172,6 +182,16 @@ Live.getMessage = (callback) => chrome.runtime.onMessage.addListener((request, s
$.fn.stopPropagation = function() {
return this.on('click', (e) => e.stopPropagation());
};
$.getTop = function(element) {
var offset = element.offsetTop;
element.offsetParent !== null ? offset += $.getTop(element.offsetParent) : 0;
return offset;
};
$.getLeft = function(element) {
var offset = element.offsetLeft;
element.offsetParent !== null ? offset += $.getLeft(element.offsetParent) : 0;
return offset;
};

Live.init = function(callback) {
ModuleStore.init();
Expand Down
3 changes: 2 additions & 1 deletion src/bilibili_live_inject.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ i.bh-icon.tv-init { background-position: 0 -20px; }
i.bh-icon.tv-exist { background-position: -20px -20px; }
i.bh-icon.tv-enabled { background-position: -40px -20px; }

.row-item { margin-right: 10px !important; }
.hide { display: none !important; }
.bh-title {
display: inline-block;
font-size: 15px;
margin: 0;
margin-bottom: 10px;
}
.hide { display: none !important; }
.live-hover-panel hr {
margin-top: -5px;
margin-bottom: 10px;
Expand Down
10 changes: 4 additions & 6 deletions src/options/updatelog.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
<h2>更新日志</h2>
<p class="log-version">V0.0.11</p>
<p><code>新增</code> </p>
<p class="log-version">V0.0.12</p>
<p><code>新增</code> 直播设置支持更多选项</p>
<!--<p><code>新增</code> </p>TODO 赠送礼物增强-->
<p><code>优化</code> 自动签到仅在一个直播间开启</p>
<p><code>优化</code> </p>
<p><code>优化</code> </p>
<p><code>修复</code> </p>
<p><code>优化</code> 无法赠送礼物包裹内物品时显示提示</p>
<p><code>修复</code> B站改版导致部分直播页面错位的问题</p>
<hr>
<p class="log-version">V0.0.11</p>
<p><code>新增</code> 直播设置支持更多选项</p>
<!--<p><code>新增</code> </p>TODO 赠送礼物增强-->
<p><code>优化</code> 取消检测其他插件机制</p>
<p><code>优化</code> 通知图标显示图标多样化</p>
<p><code>优化</code> 自动领取瓜子后瓜子数量动态更新</p>
Expand Down

0 comments on commit 29ac981

Please sign in to comment.