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

Commit

Permalink
直播功能基本完成
Browse files Browse the repository at this point in the history
  • Loading branch information
MoeHero committed Apr 1, 2017
1 parent 374de8e commit c74fd78
Show file tree
Hide file tree
Showing 25 changed files with 67,068 additions and 2 deletions.
43 changes: 43 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"env": {
"browser": true,
"jquery": true
},
"globals": {
"chrome": false
},
"rules": {
"no-cond-assign": 2,
"no-dupe-args": 2,
"no-dupe-keys": 2,
"no-duplicate-case": 2,
"no-empty": 2,
"no-empty-function": 2,
"no-eq-null": 2,
"no-labels": 2,
"no-new": 2,
"no-script-url": 2,
"no-unused-expressions": [2, {"allowShortCircuit": true}],
"no-useless-escape": 2,
"wrap-iife": 2,
"no-unused-vars": 2,
"no-use-before-define": 2,
"eol-last": 2,
"indent": 2,
"no-bitwise": 2,
"no-multiple-empty-lines": 2,
"no-trailing-spaces": 2,
"valid-typeof": 2,
"curly": [2, "all"],
"dot-location": [2, "property"],
"dot-notation": [2, {"allowKeywords": true}],
"no-self-assign": 2,
"no-self-compare": 2,
"no-sequences": 2,
"array-bracket-spacing": 2,
"comma-spacing": [2, {"before": false, "after": true}],
"no-mixed-spaces-and-tabs": 2,
"quotes": [2, "single"],
"semi": [2, "always"]
}
}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules/
debug/
build/
BilibiliHelper.pem
21 changes: 21 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
language: node_js
node_js:
- node
cache:
directories:
- node_modules
before_script:
- openssl aes-256-cbc -K $encrypted_bf6d36bb5210_key -iv $encrypted_bf6d36bb5210_iv -in BilibiliHelper.pem.enc -out BilibiliHelper.pem -d
script:
- npm run grunt
deploy:
provider: releases
api_key:
secure: aTkoWnQjQKC0Vvbxhh84mPotZl5yISFKq01Gf1WJHLQDIikAzM3chIL/VyHtgllx8KvbLLZdAx0377lSwY5kCco0m33+TFaFXWV3zymfh0s0HnwW3NO9T1zViZZAjO2+1cRTI2MulAOuugC4O6DPdjMZDWzKPJOLFR4xfUA11xzcsN5unpNvNYIJwxK2MnzN43uUGEO+rFCWeZlPrDm3YZttVyFaDkhSaU/yfGp31sOdifYrJ+ylmysi4G2wSX1HS7cxc/Fy15bqmBfvFPwccKy3TS9Z7BJDEyNGoTRDajyZuPbuUNqNUnm6nzS1+n4CMqt1z1eKci2THH/TE4KKOlDdH7FMrAGDPiCXUmpM41kxkkA8uv+aA+zuhzKOJFbtV7RY/e6arQfVlBKoR7uPQp+4Pigz0KcHffh03QT0EmwU7QmRFtw6xYh5QPN/tYIztdf7kRhvjfUpjzMwUQucFRMh9Hil4XYU8EtFgOtdR5o0qzrKuvHEDQAwqQU9j9EMweRyBYlWcd+Hj6/7y5Y9MUFULzjuMFgWFhCISwNbiFTiOTh25XPbIUszk3GI8YD3OsaZZT1BXHrl5+jAdiIEqj0SY8EgPiMxwyLviEX+7C14XTQ+JOy3r+Y5vf+FaFzr+V5gaRGgiXcuPb7zTBo3Dv38+WcZhM0NSCLZmUjw3BQ=
file_glob: true
file:
- build/BilibiliHelper.crx
- build/BilibiliHelper.zip
skip_cleanup: true
on:
tags: true
Binary file added BilibiliHelper.pem.enc
Binary file not shown.
132 changes: 132 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
module.exports = function(grunt) {
grunt.loadNpmTasks('gruntify-eslint');
require('load-grunt-tasks')(grunt);

grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
eslint: {
main: {
src: ['Gruntfile.js', 'src/**/*.js', '!src/**/**.min.js'],
},
},
htmlmin: {
main: {
options: {
collapseBooleanAttributes: true,
collapseWhitespace: true,
minifyCSS: true,
minifyJS: true,
removeComments: true,
},
files: [{
expand: true,
cwd: 'src',
src: '**/*.html',
dest: 'build/src/',
}],
}
},
cssmin: {
main: {
files: [{
expand: true,
cwd: 'src',
src: ['**/*.css', '!**/*.min.css'],
dest: 'build/src/',
ext: '.min.css',
}],
},
},
uglify: {
options: {
preserveComments: 'some',
},
main: {
files: [{
expand: true,
cwd: 'src',
src: ['**/*.js', '!**/*.min.js'],
dest: 'build/src/',
ext: '.min.js',
}],
},
},
copy: {
build: {
files: [{
expand: true,
cwd: 'src',
src: ['**/**', '!**/*.html', '!**/*.js', '**/*.min.js', '!**/*.css', '**/*.min.css'],
dest: 'build/src',
}],
},
debug: {
files: [{
expand: true,
cwd: 'src',
src: ['**/**', '!**/*.js', '**/*.min.js', '!**/*.css', '**/*.min.css'],
dest: 'debug/src',
}, {
expand: true,
cwd: 'src',
src: ['**/*.js', '!**/*.min.js'],
dest: 'debug/src',
ext: '.min.js',
}, {
expand: true,
cwd: 'src',
src: ['**/*.css', '!**/*.min.css'],
dest: 'debug/src',
ext: '.min.css',
}],
},
},
manifestSync: {
build: {
options: {
syncManifestFields: ['description', 'version'],
manifests: {
chromeExtension: 'build/src/manifest.json',
},
},
},
debug: {
options: {
syncManifestFields: ['description', 'version'],
manifests: {
chromeExtension: 'debug/src/manifest.json',
},
},
},
},
crx: {
zip: {
src: 'build/src/**',
dest: 'build/BilibiliHelper.zip',
},
crx: {
options: {
privateKey: 'BilibiliHelper.pem',
},
src: 'build/src/**',
dest: 'build/BilibiliHelper.crx',
},
},
clean: {
build: {
src: ['build/**'],
},
debug: {
src: ['debug/**'],
},
},
});

grunt.registerTask('default', 'build');
grunt.registerTask('build', ['eslint', 'htmlmin', 'cssmin', 'uglify', 'copy:build', 'manifestSync:build', 'buildnumber:build', 'crx:crx', 'crx:zip']);
grunt.registerTask('buildnumber', function(arg) {
var json = {buildnumber: arg == 'build' ? process.env.TRAVIS_BUILD_NUMBER : -1};
grunt.file.write((arg == 'build' ? 'build' : 'debug') + '/src/version.json', JSON.stringify(json));
});
grunt.registerTask('debug', ['eslint', 'copy:debug', 'manifestSync:debug', 'buildnumber:debug']);
};
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
# BilibiliHelper
Bilibili助手
# BilibilHelper

[![license](https://img.shields.io/badge/license-MPL--2.0-blue.svg)](https://github.com/MoeHero/BilibiliHelper/blob/master/LICENSE)
[![GitHub release](https://img.shields.io/github/release/MoeHero/BilibiliHelper.svg)](https://github.com/MoeHero/BilibilHelper/releases)
[![Github All Releases](https://img.shields.io/github/downloads/MoeHero/BilibiliHelper/total.svg)](https://github.com/MoeHero/BilibiliHelper/releases)
[![Build Status](https://travis-ci.org/MoeHero/BilibiliHelper.svg?branch=master)](https://travis-ci.org/MoeHero/BilibiliHelper)

### Bilibili助手

本软件使用[MPL-2.0](/MoeHero/BilibiliHelper/blob/master/LICENSE)许可协议
部分代码参考自[zacyu](/zacyu)[jjj201200](/jjj201200)基于[MIT](/zacyu/bilibili-helper/blob/master/LICENSE)许可协议开发的软件[bilibili-helper](/zacyu/bilibili-helper)
29 changes: 29 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "bilibili-helper",
"description": "Bilibili助手",
"version": "0.0.1",
"main": "index.js",
"author": "MoeHero",
"license": "MPL-2.0",
"homepage": "https://github.com/MoeHero/BilibiliHelper#readme",
"repository": "https://github.com/MoeHero/BilibiliHelper",
"bugs": {
"url": "https://github.com/MoeHero/BilibiliHelper/issues"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 0",
"grunt": "grunt"
},
"devDependencies": {
"grunt": "^1.0.1",
"grunt-contrib-clean": "^1.0.0",
"grunt-contrib-copy": "^1.0.0",
"grunt-contrib-cssmin": "^2.0.0",
"grunt-contrib-htmlmin": "^2.3.0",
"grunt-contrib-uglify": "^2.2.0",
"grunt-crx": "^1.0.5",
"grunt-manifest-sync": "^1.2.1",
"gruntify-eslint": "^3.1.0",
"load-grunt-tasks": "^3.5.2"
}
}
88 changes: 88 additions & 0 deletions src/background.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
console.log('Start Loading...');

var Treasure = {
showID: false,
tabID: false,
getTreasure: function() {
return Treasure;
},
setTreasure: function(options) {
Treasure.showID = options.showID;
Treasure.tabID = options.tabID;
},
delTreasure: function() {
Treasure.showID = false;
Treasure.tabID = false;
}
};

var SmallTV = {
showID: false,
tabID: false,
getSmallTV: function() {
return SmallTV;
},
setSmallTV: function(options) {
SmallTV.showID = options.showID;
SmallTV.tabID = options.tabID;
},
delSmallTV: function() {
SmallTV.showID = false;
SmallTV.tabID = false;
}
};

var Options = {};

chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tabInfo) {
if (changeInfo.status == 'complete' &&
tabInfo.status == 'complete' &&
tabInfo.url.indexOf('live.bilibili.com') != -1) {
chrome.tabs.executeScript(tabId, {'file': './jquery-3.1.1.min.js'});
chrome.tabs.executeScript(tabId, {'file': './ocrad.min.js'});
chrome.tabs.executeScript(tabId, {'file': './store.min.js'});
chrome.tabs.executeScript(tabId, {'file': './bilibili_live.min.js'});
console.log('Execute Script: ' + tabInfo.url);
}
});

chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
switch(request.command) {
case 'getTreasure':
sendResponse(Treasure.getTreasure());
break;
case 'setTreasure':
Treasure.setTreasure({tabID: sender.tab.id, showID: request.showID});
break;
case 'delTreasure':
sendResponse(Treasure.delTreasure());
break;
case 'checkNewTask':
chrome.tabs.sendMessage(Treasure.tabID, {command: 'checkNewTask'});
break;
case 'getSmallTV':
sendResponse(SmallTV.getSmallTV());
break;
case 'setSmallTV':
SmallTV.setSmallTV({tabID: sender.tab.id, showID: request.showID});
break;
case 'delSmallTV':
sendResponse(SmallTV.delSmallTV());
break;
case 'getOptions':
sendResponse(Options);
break;
}
});

chrome.runtime.onMessageExternal.addListener(function(request, sender) {
chrome.tabs.sendMessage(sender.tab.id, request);
});

$.getJSON('version.json').promise().done(function(result) {
Options.buildNumber = result.buildnumber;
Options.extensionID = chrome.i18n.getMessage('@@extension_id');
Options.version = chrome.runtime.getManifest().version;
});

console.log('Loaded');
Loading

0 comments on commit c74fd78

Please sign in to comment.