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

Commit

Permalink
Merge branch 'release/V0.0.20'
Browse files Browse the repository at this point in the history
  • Loading branch information
MoeHero committed May 31, 2017
2 parents 1764a7f + b1d5660 commit a52bebf
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/live/FuncDanmuEnhance.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class FuncDanmuEnhance {
}
static sendDanmu_player(danmu) {
return new Promise((resolve) => {
Helper.addScriptByText(`bh_sendDanmu(${danmu}, '0x'${this.danmuColorList[this.selectDanmuColor]}, ${this.selectDanmuMode});`).remove();
Helper.addScriptByText(`bh_sendDanmu('${Helper.escape(danmu)}', '0x${this.danmuColorList[this.selectDanmuColor]}', ${this.selectDanmuMode});`).remove();
resolve();
});
}
Expand Down
3 changes: 3 additions & 0 deletions src/live/Helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ Helper.format = (template, data) => {
}
return template;
};
Helper.escape = string => {
return string.replace(/([\\'"&])+?/g, '\\$1');
};
Helper.localize = {//TODO 重构 去除不必要文本
helper: 'Bilibili助手',
enabled: '已启用',
Expand Down
2 changes: 1 addition & 1 deletion src/live_inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ function bh_getDanmuInfo() {
chrome.runtime.sendMessage(extensionID, {command: 'getDanmuInfo', danmuInfo: danmuInfo});
}
function bh_sendDanmu(danmu, color, mode) {
window.LivePlayer && window.LivePlayer(danmu, color, mode);
window.LivePlayer && window.LivePlayer.sendMsg(danmu, color, mode);
}
console.log('%c直播间脚本注入成功~', 'color:#FFF;background-color:#57D2F7;padding:5px;border-radius:7px;line-height:30px;');

0 comments on commit a52bebf

Please sign in to comment.