Skip to content

Commit

Permalink
修复弹幕和评论问题
Browse files Browse the repository at this point in the history
  • Loading branch information
jjj201200 committed Jun 25, 2020
1 parent aa90dff commit 0a70d96
Show file tree
Hide file tree
Showing 6 changed files with 372 additions and 333 deletions.
200 changes: 100 additions & 100 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,102 +1,102 @@
{
"name": "bilibili-helper-master",
"version": "1.2.21-beta.1",
"description": "bilibili-helper",
"main": "index.js",
"dependencies": {
"color": "^3.0.0",
"fetch-progress": "^1.2.0",
"ffmpeg.js": "^3.1.9001",
"history": "^4.7.2",
"jquery": "^3.4.0",
"lodash": "^4.17.10",
"md5": "^2.2.1",
"measurement-protocol": "^0.1.0",
"mobx": "^5.0.3",
"mobx-react": "^5.2.3",
"mobx-react-router": "^4.0.4",
"moment": "^2.22.2",
"npm": "^6.6.0",
"ocradjs-browser.js": "^1.0.2",
"prop-types": "^15.6.2",
"protobufjs": "^6.9.0",
"react": "^16.4.1",
"react-dom": "^16.4.1",
"react-ga": "^2.7.0",
"react-router": "^4.3.1",
"react-transition-group": "^1.2.1",
"react-virtualized": "^9.21.0",
"store": "^2.0.12",
"styled-components": "^4.1.2",
"systemjs": "^2.1.1",
"universal-analytics": "^0.4.20",
"url-parse": "^1.4.3",
"uuid": "^8.1.0"
},
"devDependencies": {
"babel-core": "^6.26.3",
"babel-eslint": "^10.0.1",
"babel-loader": "^7.1.4",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-import": "^1.6.5",
"babel-plugin-lodash": "^3.3.2",
"babel-plugin-styled-components": "^1.4.0",
"babel-plugin-syntax-dynamic-import": "^6.18.0",
"babel-plugin-transform-builtin-classes": "^0.6.1",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-decorators": "^6.24.1",
"babel-plugin-transform-decorators-legacy": "^1.3.5",
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.0",
"babel-plugin-transform-es2015-modules-umd": "^6.24.1",
"babel-plugin-transform-es3-member-expression-literals": "^6.22.0",
"babel-plugin-transform-es3-property-literals": "^6.22.0",
"babel-plugin-transform-function-bind": "^6.22.0",
"babel-plugin-transform-object-assign": "^6.22.0",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-plugin-transform-react-jsx": "^6.24.1",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.7.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"clean-webpack-plugin": "^0.1.19",
"concurrently": "^4.1.0",
"copy-webpack-plugin": "^4.5.1",
"css-loader": "^2.1.0",
"cssnano": "^4.0.3",
"eslint": "^5.9.0",
"eslint-loader": "^2.1.1",
"eslint-plugin-react": "^7.11.1",
"html-webpack-plugin": "^4.0.0-alpha",
"json-loader": "^0.5.7",
"load-grunt-tasks": "^3.5.2",
"merge-jsons-webpack-plugin": "^1.0.18",
"mini-css-extract-plugin": "^0.4.0",
"node-sass": "^4.9.0",
"optimize-css-assets-webpack-plugin": "^5.0.0",
"react-hot-loader": "^4.3.3",
"sass-loader": "^7.0.3",
"style-loader": "^0.21.0",
"uglifyjs-webpack-plugin": "^1.2.7",
"webpack": "^4.10.2",
"webpack-bundle-analyzer": "^3.1.0",
"webpack-cli": "^3.0.3",
"webpack-dev-server": "^3.1.4",
"write-json-webpack-plugin": "^1.1.0",
"zip-webpack-plugin": "^3.0.0"
},
"peerDependencies": {
"@babel/core": "^7.0.0-beta.49"
},
"scripts": {
"grunt": "grunt",
"watch": "webpack --env.DEBUG=true --config=webpack.config.development.js --watch --progress",
"build": "webpack --production --progress",
"build:test": "webpack --env.DEBUG=true --production --progress"
},
"author": "zacyu & drowsyflesh",
"license": "MIT",
"repository": "https://github.com/zacyu/bilibili-helper",
"readme": "/source/README.md"
"name": "bilibili-helper-master",
"version": "1.2.21-beta.1",
"description": "bilibili-helper",
"main": "index.js",
"dependencies": {
"color": "^3.0.0",
"fetch-progress": "^1.2.0",
"ffmpeg.js": "^3.1.9001",
"history": "^4.7.2",
"jquery": "^3.4.0",
"lodash": "^4.17.10",
"md5": "^2.2.1",
"measurement-protocol": "^0.1.0",
"mobx": "^5.0.3",
"mobx-react": "^5.2.3",
"mobx-react-router": "^4.0.4",
"moment": "^2.22.2",
"npm": "^6.6.0",
"ocradjs-browser.js": "^1.0.2",
"prop-types": "^15.6.2",
"protobufjs": "^6.9.0",
"react": "^16.4.1",
"react-dom": "^16.4.1",
"react-ga": "^2.7.0",
"react-router": "^4.3.1",
"react-transition-group": "^1.2.1",
"react-virtualized": "^9.21.0",
"store": "^2.0.12",
"styled-components": "^4.1.2",
"systemjs": "^2.1.1",
"universal-analytics": "^0.4.20",
"url-parse": "^1.4.3",
"uuid": "^8.1.0"
},
"devDependencies": {
"babel-core": "^6.26.3",
"babel-eslint": "^10.0.1",
"babel-loader": "^7.1.4",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-import": "^1.6.5",
"babel-plugin-lodash": "^3.3.2",
"babel-plugin-styled-components": "^1.4.0",
"babel-plugin-syntax-dynamic-import": "^6.18.0",
"babel-plugin-transform-builtin-classes": "^0.6.1",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-decorators": "^6.24.1",
"babel-plugin-transform-decorators-legacy": "^1.3.5",
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.0",
"babel-plugin-transform-es2015-modules-umd": "^6.24.1",
"babel-plugin-transform-es3-member-expression-literals": "^6.22.0",
"babel-plugin-transform-es3-property-literals": "^6.22.0",
"babel-plugin-transform-function-bind": "^6.22.0",
"babel-plugin-transform-object-assign": "^6.22.0",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-plugin-transform-react-jsx": "^6.24.1",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.7.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"clean-webpack-plugin": "^0.1.19",
"concurrently": "^4.1.0",
"copy-webpack-plugin": "^4.5.1",
"css-loader": "^2.1.0",
"cssnano": "^4.0.3",
"eslint": "^5.9.0",
"eslint-loader": "^2.1.1",
"eslint-plugin-react": "^7.11.1",
"html-webpack-plugin": "^4.0.0-alpha",
"json-loader": "^0.5.7",
"load-grunt-tasks": "^3.5.2",
"merge-jsons-webpack-plugin": "^1.0.18",
"mini-css-extract-plugin": "^0.4.0",
"node-sass": "^4.9.0",
"optimize-css-assets-webpack-plugin": "^5.0.0",
"react-hot-loader": "^4.3.3",
"sass-loader": "^7.0.3",
"style-loader": "^0.21.0",
"uglifyjs-webpack-plugin": "^1.2.7",
"webpack": "^4.10.2",
"webpack-bundle-analyzer": "^3.1.0",
"webpack-cli": "^3.0.3",
"webpack-dev-server": "^3.1.4",
"write-json-webpack-plugin": "^1.1.0",
"zip-webpack-plugin": "^3.0.0"
},
"peerDependencies": {
"@babel/core": "^7.0.0-beta.49"
},
"scripts": {
"grunt": "grunt",
"watch": "webpack --env.DEBUG=true --config=webpack.config.development.js --watch --progress",
"build": "webpack --production --progress",
"build:test": "webpack --env.DEBUG=true --production --progress"
},
"author": "zacyu & drowsyflesh",
"license": "MIT",
"repository": "https://github.com/zacyu/bilibili-helper",
"readme": "/source/README.md"
}
109 changes: 57 additions & 52 deletions src/js/modules/liveReplayDownload/UI/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,66 +12,71 @@ export class LiveReplayDownloadUI extends UI {
});
}

createBtns = () => {
this.interval('.left-container .live-record-list-cntr', 1000).then((list) => {
Array.from(list.querySelectorAll('.card')).forEach((card) => {
const href = card.querySelector('a').href;
if (href) {
const dom = document.createElement('div');
dom.classList.add('record-download');
dom.setAttribute('style', 'display:flex;flex-wrap:wrap;margin-top:6px;');
const res = href.match(/live.bilibili.com\/record\/(.+)/);
if (res) {
const title = card.querySelector('.record-title').textContent;
const button = document.createElement('button');
button.innerText = '点击获取下载数据';
button.setAttribute('style', 'width:100%;height:30px;border-radius:4px;border-color:#eef1f5;color:#333;cursor:pointer;font-size:12px;border-style:none;')
button.addEventListener('click', () => {
chrome.runtime.sendMessage({
command: 'setGAEvent',
action: 'click',
category: 'Live record download',
label: 'Live record download',
});
button.innerText = '数据获取中';
chrome.runtime.sendMessage({
command: 'getLiveRecord',
rid: res[1],
title,
}, (res) => {
if (res) {
button.remove();
res.list.forEach((fragment, index) => {
const fragmentBtn = document.createElement('a');
fragmentBtn.setAttribute('style', `display:inline-block;min-width:20px;font-size:12px;padding:6px;border:1px solid #eee;border-radius:4px;color:#7a7a7b;flex-shrink:0;margin-right:${Number.isInteger((index + 1)/5) ? 0 : 9}px;margin-bottom:9px;text-align:center;`);
fragmentBtn.setAttribute('download', '');
fragmentBtn.setAttribute('target', '__blank');
fragmentBtn.setAttribute('referrerPolicy', 'unsafe-url');
fragmentBtn.href = fragment.url;
fragmentBtn.innerText = `${index + 1}`;
dom.appendChild(fragmentBtn);
});
} else {
button.innerText = '数据获取失败';
}
});
});
Array.from(card.querySelectorAll('.record-download')).forEach((d) => d.remove());
card.appendChild(dom);
dom.appendChild(button);
}
}
});
});
}

load = (containers, settings) => {
return new Promise(resolve => {
if (!settings.on) {
return resolve();
}
this.interval('#sections-vm .room-feed .tabs', 1000).then((container) => {
let lock = false;
new MutationObserver((mutationList) => {
let same = false;
mutationList.forEach((mutation) => {
if (mutation.target.textContent === '直播回放' && !lock) {
lock = true;
this.interval('.live-record-list-cntr', 300).then((list) => {
Array.from(list.querySelectorAll('.card')).forEach((card) => {
const href = card.querySelector('a').href;
if (href) {
const dom = document.createElement('div');
dom.classList.add('record-download');
dom.setAttribute('style', 'display:flex;flex-wrap:wrap;margin-top:6px;');
const res = href.match(/live.bilibili.com\/record\/(.+)/);
if (res) {
const title = card.querySelector('.record-title').textContent;
const button = document.createElement('button');
button.innerText = '点击获取下载数据';
button.setAttribute('style', 'width:100%;height:30px;border-radius:4px;border-color:#eef1f5;color:#333;cursor:pointer;font-size:12px;')
button.addEventListener('click', () => {
chrome.runtime.sendMessage({
command: 'setGAEvent',
action: 'click',
category: 'Live record download',
label: 'Live record download',
});
button.innerText = '数据获取中';
chrome.runtime.sendMessage({
command: 'getLiveRecord',
rid: res[1],
title,
}, (res) => {
if (res) {
button.remove();
res.list.forEach((fragment, index) => {
const fragmentBtn = document.createElement('a');
fragmentBtn.setAttribute('style', `display:inline-block;min-width:20px;font-size:12px;padding:6px;border:1px solid #eee;border-radius:4px;color:#7a7a7b;flex-shrink:0;margin-right:${Number.isInteger((index + 1)/5) ? 0 : 9}px;margin-bottom:9px;text-align:center;`);
fragmentBtn.setAttribute('download', '');
fragmentBtn.setAttribute('target', '__blank');
fragmentBtn.setAttribute('referrerPolicy', 'unsafe-url');
fragmentBtn.href = fragment.url;
fragmentBtn.innerText = `${index + 1}`;
dom.appendChild(fragmentBtn);
});
} else {
button.innerText = '数据获取失败';
}
});
});
card.appendChild(dom);
dom.appendChild(button);
}
}
});
});
if (mutation.target.textContent === '直播回放'&& !same) {
same = true;
this.createBtns();
}
});
}).observe(container, {
Expand Down
2 changes: 1 addition & 1 deletion src/js/modules/liveUpCheck/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export class LiveUpCheck extends Feature {
};

initList() {
void this.getList(this.currentList);
void this.getList(this.currentList || []);
}

checkNew() {
Expand Down
41 changes: 26 additions & 15 deletions src/js/modules/proxyForWebsite/fetch/fetchImage.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,33 @@ const imageList = {};
* @return {Promise<void>}
*/
export const fetchImage = async (websitePort, {url, options, sign, model, mine}) => {
let imageBase64String = '';
if (imageList[sign]) imageBase64String = imageList[sign];
else {
imageBase64String = await fetchFromHelper(url, options)
.then(response => response)
.then((response) => {
return response.arrayBuffer().then(buffer => {
return imageList[sign] = `data:${mine};base64,` + arrayBufferToBase64(buffer);
if (url.match(/^data:image\//)) {
websitePort.postMessage({
command: 'returnFetch',
data: url,
from: 'helperProxy',
model,
sign,
});
} else {
let imageBase64String = '';
if (imageList[sign]) imageBase64String = imageList[sign];
else {
imageBase64String = await fetchFromHelper(url, options)
.then(response => response)
.then((response) => {
return response.arrayBuffer().then(buffer => {
return imageList[sign] = `data:${mine};base64,` + arrayBufferToBase64(buffer);
});
});
}
websitePort.postMessage({
command: 'returnFetch',
data: imageBase64String,
from: 'helperProxy',
model,
sign,
});
}
websitePort.postMessage({
command: 'returnFetch',
data: imageBase64String,
from: 'helperProxy',
model,
sign,
});

};

0 comments on commit 0a70d96

Please sign in to comment.