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

Commit

Permalink
[bilibili_injected.js] better ass generating
Browse files Browse the repository at this point in the history
*try to prevent generating ass for more than once for the same comments url
  • Loading branch information
myfreeer committed Nov 26, 2016
1 parent 5c7f765 commit d3a625b
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions bilibili_injected.js
Original file line number Diff line number Diff line change
Expand Up @@ -851,16 +851,17 @@
comments = comments ? comments : biliHelper.commentsUrl ? biliHelper.commentsUrl : 'http://comment.bilibili.com/' + biliHelper.cid + '.xml';
fetch(comments).then(res => res.text()).then(res => {
var response = parseXmlSafe(res);
var assData;
var assBtn = $('<a class="b-btn w">下载 ASS 格式弹幕</a>').attr('download', biliHelper.downloadFileName.replace('.xml', '.ass')).attr('href', null).click(function(e) {
var assData = '\ufeff' + generateASS(setPosition(parseXML('', response)), {
'title': getNiceSectionFilename(biliHelper.avid, biliHelper.page, biliHelper.totalPage, 1, 1),
'ori': location.href
}),
assBlob = new Blob([assData], {
e.preventDefault();
if (!assData) assData = '\ufeff' + generateASS(setPosition(parseXML('', response)), {
'title': getNiceSectionFilename(biliHelper.avid, biliHelper.page, biliHelper.totalPage, 1, 1),
'ori': location.href
});
var assBlob = new Blob([assData], {
type: 'application/octet-stream'
}),
assUrl = window.URL.createObjectURL(assBlob);
e.preventDefault();
e.target.href = assUrl;
chrome.runtime.sendMessage({
command: 'requestForDownload',
Expand Down

0 comments on commit d3a625b

Please sign in to comment.