Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/bilibili_injected.js
#	src/options.html
#	src/options.js
  • Loading branch information
zacyu committed May 10, 2017
2 parents 75b2dd1 + 8dbabb8 commit f7c5039
Show file tree
Hide file tree
Showing 14 changed files with 426 additions and 173 deletions.
2 changes: 1 addition & 1 deletion src/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
"description": "Noticefication: Live On"
},
"notificationGetTv": {
"message": "Proceed to fill out mailing address.",
"message": "Attend it.",
"description": "Noticefication: Get TV"
}
}
2 changes: 1 addition & 1 deletion src/_locales/zh_CN/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
"description": "Noticefication: Live On"
},
"notificationGetTv": {
"message": "前往填写收货地址",
"message": "前往参加",
"description": "Noticefication: Get TV"
}
}
2 changes: 1 addition & 1 deletion src/_locales/zh_TW/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
"description": "Noticefication: Live On"
},
"notificationGetTv": {
"message": "前往填寫收貨地址",
"message": "前往參加",
"description": "Noticefication: Get TV"
}
}
33 changes: 30 additions & 3 deletions src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ if (typeof (chrome.runtime.setUninstallURL) === 'function') {
Live.treasure = {};
Live.watcherRoom = {};
Live.tvs = {};
Live.tvNotification = {};

function setTreasure(data) {
if (Object.prototype.toString.call(data) === '[object Object]') {
Expand Down Expand Up @@ -455,6 +456,7 @@ chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
autowide: getOption('autowide'),
version: version,
macplayer: getOption('macplayer'),
autooffset: getOption('autooffset'),
});
return true;
case 'cidHack':
Expand Down Expand Up @@ -702,6 +704,28 @@ chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
}
});
return true; }
case 'tvNotification':
{
let data = request.data;
let roomId = data.roomId;
Live.tvNotification[roomId] = true;
chrome.notifications.create(roomId, {
type: 'basic',
iconUrl: 'http://static.hdslb.com/live-static/live-room/images/gift-section/gift-25.gif',
title: '小电视抽奖提示',
message: '直播间【' + roomId + '】正在进行小电视抽奖',
isClickable: true,
buttons: [{
title: chrome.i18n.getMessage('notificationGetTv'),
}],
}, function(id) {
setTimeout(function() {
chrome.notifications.clear(id);
}, 10000);
});

return true;
}
case 'getTVReward':
{ let rewardStr = '',
lost = '很遗憾,此次您没有中奖';
Expand Down Expand Up @@ -920,6 +944,11 @@ chrome.alarms.onAlarm.addListener(function(alarm) {
});

chrome.notifications.onButtonClicked.addListener(function(notificationId, index) {
if (Live.tvNotification[notificationId] !== undefined) {
chrome.tabs.create({
url: 'http://live.bilibili.com/' + notificationId,
});
}
if (Live.notisesIdList[notificationId] !== undefined) {
if (index === 0) {
chrome.tabs.create({
Expand Down Expand Up @@ -1098,11 +1127,9 @@ Live.notise = {
iconUrl: data.face,
title: data.nickname + chrome.i18n.getMessage('notificationLiveOn'),
message: data.roomname,
isClickable: false,
isClickable: true,
buttons: [{
title: chrome.i18n.getMessage('notificationWatch'),
}, {
title: chrome.i18n.getMessage('notificationShowAll'),
}],
}, function(id) {
Live.notisesIdList[id] = data;
Expand Down
3 changes: 2 additions & 1 deletion src/bilibiliHelperAd.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
#b_recommend,
/*live*/
.bulletins,
.live-ad-full
.live-ad-full,
.not-enough
{
display: none !important;
}
23 changes: 14 additions & 9 deletions src/bilibili_injected.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@
observer.observe(player[0], {childList: true});
}
}
function setOffset() {
$(document).scrollTop($('.b-page-body').offset().top);
}

chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
switch (request.command) {
Expand Down Expand Up @@ -197,6 +200,8 @@
}, function(response) {
// biliHelper.playerConfig = response.playerConfig;
biliHelper.version = response.version;
biliHelper.autowide = response.autowide;
biliHelper.autooffset = response.autooffset;
// biliHelper.favorHTML5 = response.html5 === 'on';
// biliHelper.replaceEnabled = response.replace === 'on';
biliHelper.originalPlayer = localStorage.getItem('bilimac_original_player') || $('#bofqi').html();
Expand Down Expand Up @@ -239,19 +244,19 @@
},
};
if (biliHelper.site === 0) {
biliHelper.helperBlock = $('<div class="block helper" id="bilibili_helper"><span class="t"><div class="icon"></div><div class="t-right"><span class="t-right-top middle">助手</span><span class="t-right-bottom">扩展菜单</span></div></span><div class="info"><div class="main"></div><div class="version">哔哩哔哩助手 ' + biliHelper.version + ' by <a href="http://weibo.com/guguke" target="_blank">@啾咕咕www</a><a class="setting b-btn w" href="' + chrome.extension.getURL('options.html') + '" target="_blank">设置</a></div></div></div>');
biliHelper.helperBlock = $('<div class="block helper" id="bilibili_helper"><span class="t"><div class="icon"></div><div class="t-right"><span class="t-right-top middle">助手</span><span class="t-right-bottom">扩展菜单</span></div></span><div class="info"><div class="main"></div><div class="version" title="' + biliHelper.version + '">哔哩哔哩助手 by <a href="http://weibo.com/guguke" target="_blank">@啾咕咕</a> <a href="http://weibo.com/ruo0037" target="_blank">@肉肉</a><a class="setting b-btn w" href="' + chrome.extension.getURL('options.html') + '" target="_blank">设置</a></div></div></div>');
biliHelper.helperBlock.find('.t').click(function() {
biliHelper.helperBlock.toggleClass('active');
});
} else if (biliHelper.site === 1) {
biliHelper.helperBlock = $('<span class="helper"><div class="v1-bangumi-info-btn" id="bilibili_helper">哔哩哔哩助手</div><div class="info"><div class="main"></div><div class="version">哔哩哔哩助手 ' + biliHelper.version + ' by <a href="http://weibo.com/guguke" target="_blank">@啾咕咕www</a><a class="setting b-btn w" href="' + chrome.extension.getURL('options.html') + '" target="_blank">设置</a></div></div></span>');
biliHelper.helperBlock = $('<span class="helper"><div class="v1-bangumi-info-btn" id="bilibili_helper">哔哩哔哩助手</div><div class="info"><div class="main"></div><div class="version" title="' + biliHelper.version + '">哔哩哔哩助手 by <a href="http://weibo.com/guguke" target="_blank">@啾咕咕</a> <a href="http://weibo.com/ruo0037" target="_blank">@肉肉</a><a class="setting b-btn w" href="' + chrome.extension.getURL('options.html') + '" target="_blank">设置</a></div></div></span>');
biliHelper.helperBlock.find('.v1-bangumi-info-btn').click(function() {
biliHelper.helperBlock.toggleClass('active');
});
}
let blockInfo = biliHelper.helperBlock.find('.info');
biliHelper.mainBlock = blockInfo.find('.main');
biliHelper.mainBlock.infoSection = $('<div class="section video"><h3>视频信息</h3><p><span></span><span>aid: ' + biliHelper.avid + '</span><span>pg: ' + biliHelper.page + '</span></p></div>');
biliHelper.mainBlock.infoSection = $('<div class="section video hidden"><h3>视频信息</h3><p><span></span><span>aid: ' + biliHelper.avid + '</span><span>pg: ' + biliHelper.page + '</span></p></div>');
biliHelper.mainBlock.append(biliHelper.mainBlock.infoSection);
biliHelper.mainBlock.dblclick(function(e) {
if (e.shiftKey) {
Expand Down Expand Up @@ -376,6 +381,12 @@
biliHelper.work();
return false;
}
if (biliHelper.autowide === 'on') {
setWide();
}
if (biliHelper.autooffset === 'on') {
setOffset();
}
if (typeof videoInfo.code !== 'undefined') {
if (biliHelper.page !== 1) {
chrome.runtime.sendMessage({
Expand Down Expand Up @@ -545,12 +556,6 @@
eval(evalCode);
}, 1000);

/* if (biliHelper.cid && !biliHelper.favorHTML5 && localStorage.getItem('bilimac_player_type') !== 'force') {
$('#loading-notice').fadeOut(300, function() {
biliHelper.switcher.swf();
});
} */

if (!biliHelper.cid) {
biliHelper.error = '错误' + videoInfo.code + ': ' + videoInfo.error;
biliHelper.mainBlock.errorSection = $('<div class="section error"><h3>Cid 获取失败</h3><p><span></span><span>' + parseSafe(biliHelper.error) + '</span></p></div>');
Expand Down
Loading

0 comments on commit f7c5039

Please sign in to comment.