From c533b4ccf88702e9c8af156f51f1944f3a103c19 Mon Sep 17 00:00:00 2001 From: MoeHero Date: Sun, 30 Apr 2017 14:46:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E7=94=A8babili=E5=8E=8B=E7=BC=A9=20?= =?UTF-8?q?=E9=87=8D=E6=9E=84=E9=83=A8=E5=88=86=E4=BB=A3=E7=A0=81=20?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E9=A2=86=E5=8F=96=E5=BA=94=E6=8F=B4=E6=A3=92?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gulpfile.js | 9 ++------- package.json | 8 +++----- src/background.js | 1 + src/bilibili_live/FuncGiftPackage.class.js | 14 ++++++++++---- src/bilibili_live/FuncLighten.class.js | 8 ++++++-- src/bilibili_live/FuncLiveSetting.class.js | 5 ++++- src/bilibili_live/FuncSmallTV.class.js | 10 +++++++++- src/bilibili_live/FuncTreasure.class.js | 7 +++++++ src/options/options.html | 3 +++ src/options/updatelog.html | 15 +++++++-------- 10 files changed, 52 insertions(+), 28 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 1e64b2b..6ab5eca 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,7 +1,6 @@ var gulp = require('gulp'); var $ = require('gulp-load-plugins')(); var lazypipe = require('lazypipe'); -var closureCompiler = require('google-closure-compiler').gulp(); var fs = require('fs'); var pkg = JSON.parse(fs.readFileSync('package.json', 'utf8')); @@ -36,11 +35,7 @@ gulp.task('live', function() { .pipe($.order(['Live*.js', 'Module*.class.js', 'Func*.class.js', '!Core.js', 'Core.js'])) .pipe($.jshintChannel()) .pipe($.concat('bilibili_live.js')) - .pipe($.if(path == 'release', closureCompiler({ - js_output_file: 'bilibili_live.js', - formatting: 'SINGLE_QUOTES', - assume_function_wrapper: 'true' - }))) + .pipe($.if(path == 'release', $.babel({presets: ['babili']}))) .pipe($.rename({suffix: '.min'})) .pipe(gulp.dest(path + '/src/')); }); @@ -48,7 +43,7 @@ gulp.task('live', function() { gulp.task('script', function() { return gulp.src(['./src/**/!(*.min).js', '!src/bilibili_live/*.js']) .pipe($.jshintChannel()) - .pipe($.if(path == 'release', $.uglify())) + .pipe($.if(path == 'release', $.babel({presets: ['babili']}))) .pipe($.rename({suffix: '.min'})) .pipe(gulp.dest(path + '/src/')); }); diff --git a/package.json b/package.json index 030169c..a776a45 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "bilibili-helper", "description": "Bilibili助手", - "version": "0.0.7", + "version": "0.0.8", "author": "MoeHero", "license": "MPL-2.0", "homepage": "https://github.com/MoeHero/BilibiliHelper#readme", @@ -14,7 +14,9 @@ "gulp": "gulp release" }, "devDependencies": { + "babel-preset-babili": "0.0.12", "gulp": "^3.9.1", + "gulp-babel": "^6.1.2", "gulp-clean-css": "^3.0.4", "gulp-concat": "^2.6.1", "gulp-crx-pack": "^1.0.1", @@ -25,13 +27,9 @@ "gulp-order": "^1.1.1", "gulp-rename": "^1.2.2", "gulp-sequence": "^0.4.6", - "gulp-uglify": "^2.1.2", "gulp-zip": "^4.0.0", "jshint": "^2.9.4", "jshint-stylish": "^2.2.1", "lazypipe": "^1.0.1" - }, - "dependencies": { - "google-closure-compiler": "^20170409.0.0" } } diff --git a/src/background.js b/src/background.js index 64ec869..ae5d30d 100644 --- a/src/background.js +++ b/src/background.js @@ -51,6 +51,7 @@ var Option = { live_autoSmallTV: true, live_giftPackage: true, live_liveSetting: true, + live_lighten: true, live: true, notify_autoSign: true, notify_autoTreasure: true, diff --git a/src/bilibili_live/FuncGiftPackage.class.js b/src/bilibili_live/FuncGiftPackage.class.js index 6dbf5a8..093dcea 100644 --- a/src/bilibili_live/FuncGiftPackage.class.js +++ b/src/bilibili_live/FuncGiftPackage.class.js @@ -1,11 +1,15 @@ -/* globals ModuleConsole,ModuleDom,ModuleNotify,ModuleStore */ -class FuncGiftPackage {//TODO 重构 +class FuncGiftPackage { static init() { if(!Live.option.live || !Live.option.live_giftPackage) { return; } this.numberGroup = ['1', '5', '10', '50', '100', '5%', '10%', '50%', '80%', 'MAX']; + this.initDOM(); + this.addEvent(); + } + + static initDOM() { this.package = $('.items-package').clone(); this.packageButton = this.package.find('a'); this.packagePanel = this.package.find('.gifts-package-panel'); @@ -27,7 +31,8 @@ class FuncGiftPackage {//TODO 重构 this.packagePanel.find('.live-tips').remove(); $('.items-package').after(this.package).remove(); $('#gift-package-send-panel').after(this.sendPanel).remove(); - + } + static addEvent() { this.packagePanel.on('click', (event) => event.stopPropagation()); this.sendPanel.on('click', (event) => event.stopPropagation()); $(document).on('click', () => this.packagePanel.fadeOut(200)); @@ -41,7 +46,7 @@ class FuncGiftPackage {//TODO 重构 if(request.command && request.command == 'openGiftPackage') { this.openGiftPackage(); } - });//.focus() + }); Live.getMessage((request) => { if(request.command && request.command == 'sendGiftCallback') { let result = request.result; @@ -61,6 +66,7 @@ class FuncGiftPackage {//TODO 重构 } else { console.log(result); } + this.sendPanelCount.focus(); } }); } diff --git a/src/bilibili_live/FuncLighten.class.js b/src/bilibili_live/FuncLighten.class.js index d8b23f6..2d5666d 100644 --- a/src/bilibili_live/FuncLighten.class.js +++ b/src/bilibili_live/FuncLighten.class.js @@ -1,10 +1,15 @@ /* globals ModuleStore,ModuleDom,ModuleNotify,ModuleConsole */ class FuncLighten { static init() { - if(!Live.option.live || !Live.option.live) { + if(!Live.option.live || !Live.option.live_lighten) { return; } //ModuleDom.smallTV_init(); + + this.addEvent(); + } + + static addEvent() { Live.sendMessage({command: 'getLighten'}, (result) => { if(!result.showID) { Live.sendMessage({command: 'setLighten', showID: Live.showID}); @@ -13,7 +18,6 @@ class FuncLighten { }); Live.getMessage((request) => { if(request.cmd && request.cmd == 'SYS_MSG' && request.msg && request.msg.includes('领取应援棒') && request.url) { - console.log(request); this.join(request.url.match(/com\/(.+)/)[1]); } }); diff --git a/src/bilibili_live/FuncLiveSetting.class.js b/src/bilibili_live/FuncLiveSetting.class.js index e7ab9ed..900c7d4 100644 --- a/src/bilibili_live/FuncLiveSetting.class.js +++ b/src/bilibili_live/FuncLiveSetting.class.js @@ -8,7 +8,9 @@ class FuncLiveSetting { vip: {name: '老爷进场', click: this.vip_click, state: true}, 'super-gift': {name: '礼物连击', click: this.super_gift_click, state: true} }; + this.initDOM(); + this.addEvent(); } static initDOM() { @@ -24,7 +26,8 @@ class FuncLiveSetting { } this.liveSettingPanel.append(ul); $('.profile-ctrl').append(this.liveSettingPanel).append(this.liveSettingButton); - + } + static addEvnet() { this.liveSettingPanel.on('click', (event) => event.stopPropagation()); $(document).on('click', () => this.liveSettingPanel.fadeOut(200)); diff --git a/src/bilibili_live/FuncSmallTV.class.js b/src/bilibili_live/FuncSmallTV.class.js index 038a4f2..be217fb 100644 --- a/src/bilibili_live/FuncSmallTV.class.js +++ b/src/bilibili_live/FuncSmallTV.class.js @@ -4,9 +4,17 @@ class FuncSmallTV { if(!Live.option.live || !Live.option.live_autoSmallTV) { return; } - ModuleDom.smallTV_init(); this.countdown = {}; this.awardName = {1: '小电视抱枕', 2: '蓝白胖次', 3: 'B坷垃', 4: '喵娘', 5: '爱心便当', 6: '银瓜子', 7: '辣条'}; + + this.initDOM(); + this.addEvent(); + } + + static initDOM() { + ModuleDom.smallTV_init(); + } + static addEvent() { Live.sendMessage({command: 'getSmallTV'}, (result) => { if(!result.showID) { Live.sendMessage({command: 'setSmallTV', showID: Live.showID}); diff --git a/src/bilibili_live/FuncTreasure.class.js b/src/bilibili_live/FuncTreasure.class.js index 29e7dbb..0ba437d 100644 --- a/src/bilibili_live/FuncTreasure.class.js +++ b/src/bilibili_live/FuncTreasure.class.js @@ -4,11 +4,18 @@ class FuncTreasure { if(!Live.option.live || !Live.option.live_autoTreasure) { return; } + this.initDOM(); + this.addEvent(); + } + + static initDOM() { ModuleDom.treasure_init(); this.canvas = document.createElement('canvas'); this.canvas.width = 120; this.canvas.height = 40; this.canvas = this.canvas.getContext('2d'); + } + static addEvent() { Live.sendMessage({command: 'getTreasure'}, (result) => { if(!result.showID) { Live.sendMessage({command: 'setTreasure', showID: Live.showID}); diff --git a/src/options/options.html b/src/options/options.html index c16dc59..57c055c 100644 --- a/src/options/options.html +++ b/src/options/options.html @@ -48,6 +48,9 @@

直播功能设置

  • 自动参加小电视抽奖
  • +
  • + 自动领取应援棒 +
  • 礼物包裹增强
  • diff --git a/src/options/updatelog.html b/src/options/updatelog.html index 0b38217..3106d41 100644 --- a/src/options/updatelog.html +++ b/src/options/updatelog.html @@ -1,9 +1,14 @@

    更新日志

    +

    V0.0.8

    + +

    新增 自动领取应援棒支持在设置内开关

    + + +

    修复 工作不正常的问题

    +

    V0.0.7

    新增 自动领取应援棒

    -

    新增 直播设置功能支持在设置内开关

    -

    优化 改变直播设置后会自动滚动到最底部

    修复 播放器内礼物包裹按钮不能打开礼物包裹的问题


    @@ -14,10 +19,4 @@

    更新日志

    修复 小电视领取成功后不计数的问题

    修复 小电视领取成功后没有提示的问题

    修复 领瓜子重复倒计时导致瓜子无法领取的问题

    -
    -

    V0.0.5

    -

    新增 礼物包裹增强

    -

    优化 自动小电视支持显示当前状态

    -

    优化 更改标题下方提示信息图标的样式

    -

    优化 网络差的情况下各项功能的稳定性提升


    \ No newline at end of file