-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
1,543 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
module.exports = { | ||
root: true, | ||
extends: 'eslint:recommended', | ||
parserOptions: { | ||
ecmaVersion: 8, | ||
ecmaFeatures: { | ||
impliedStrict: true, | ||
}, | ||
}, | ||
env: { | ||
es6: true, | ||
browser: true, | ||
worker: true, | ||
webextensions: true, | ||
}, | ||
"rules": { | ||
'linebreak-style': ['warn', 'unix'], | ||
'unicode-bom': ['warn', 'never'], | ||
'no-trailing-spaces': ['warn'], | ||
'no-multi-spaces': ['warn'], | ||
'no-tabs': ['warn'], | ||
'eol-last': ['warn'], | ||
'indent': ['warn', 2, { flatTernaryExpressions: true }], | ||
'semi': ['warn', 'always'], | ||
'no-extra-semi': ['off'], | ||
'comma-dangle': ['warn', 'always-multiline'], | ||
|
||
'no-multiple-empty-lines': ['warn', { max: 2 }], | ||
'quotes': ['warn', 'single', { avoidEscape: true, allowTemplateLiterals: true }], | ||
'arrow-parens': ['warn', 'as-needed'], | ||
'quote-props': ['warn', 'as-needed', { numbers: true }], | ||
'dot-notation': ['warn'], | ||
|
||
'arrow-spacing': ['warn'], | ||
'block-spacing': ['warn'], | ||
'comma-spacing': ['warn'], | ||
'semi-spacing': ['warn'], | ||
'computed-property-spacing': ['warn'], | ||
'func-call-spacing': ['warn'], | ||
'key-spacing': ['warn'], | ||
'switch-colon-spacing': ['warn'], | ||
'keyword-spacing': ['warn'], | ||
'object-curly-spacing': ['warn', 'always'], | ||
'array-bracket-spacing': ['warn', 'never'], | ||
'template-tag-spacing': ['warn'], | ||
'space-unary-ops': ['warn'], | ||
'rest-spread-spacing': ['warn'], | ||
'space-infix-ops': ['warn'], | ||
'operator-linebreak': ['warn', 'after'], | ||
'implicit-arrow-linebreak': ['warn'], | ||
'no-whitespace-before-property': ['warn'], | ||
'space-before-function-paren': ['warn', {anonymous: 'always', named: 'never', asyncArrow: 'always'}], | ||
'space-in-parens': ['warn'], | ||
'spaced-comment': ['warn', 'always', { | ||
line: { markers: ['/'] }, | ||
block: { markers: ['!'], exceptions: ['*'] } | ||
}], | ||
'brace-style': ['warn', '1tbs', { allowSingleLine: true }], | ||
'func-style': ['warn', 'expression', { allowArrowFunctions: true }], | ||
'id-length': ['warn', { min: 0, max: 40, properties: 'never' }], | ||
|
||
'eqeqeq': ['warn', 'always', {'null': 'ignore'}], | ||
'wrap-iife': ['warn', 'outside'], | ||
'yoda': ['warn', 'never', { onlyEquality: true }], | ||
'no-var': ['warn'], | ||
'no-constant-condition': ['warn', { checkLoops: false }], | ||
'no-empty': ['warn'], | ||
|
||
'no-undefined': ['warn'], | ||
'no-shadow-restricted-names': ['warn'], | ||
'no-throw-literal': ['warn'], | ||
'no-eval': ['error'], | ||
'no-implied-eval': ['error'], | ||
'no-unused-vars': ['off'], | ||
'no-implicit-globals': ['error'], | ||
'no-new-wrappers': ['warn'], | ||
'no-proto': ['warn'], | ||
'operator-assignment': ['warn', 'always'], | ||
'no-control-regex': ['off'], | ||
|
||
'no-extra-label': ['warn'], | ||
|
||
'consistent-return': ['warn'], | ||
|
||
'radix': ['warn'], | ||
|
||
'complexity': ['warn'], | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
## ASS Danmaku | ||
|
||
Download danmaku (video comments) in ASS format from AcFun & bilibili. Watch video on supported site, and danmaku download button will appear on the right of address bar. | ||
|
||
### Privacy | ||
|
||
This extension do not collect any information from your computer. | ||
|
||
This extension do not send or modify any network connection. Your danmaku file is converted offline. | ||
|
||
### License | ||
|
||
All source code is licensed under the Mozilla Public License. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
{ | ||
"extensionName": { | ||
"message": "ASS Danmaku", | ||
"description": "Name of the extension." | ||
}, | ||
"extensionDescription": { | ||
"message": "Download danmaku (video comments) in ASS format from AcFun & bilibili. Watch video on supported site, and danmaku download button will appear on the right of address bar.", | ||
"description": "Description of the extension." | ||
}, | ||
"extensionButtonTitle": { | ||
"message": "Download Danmaku", | ||
"description": "Title of the extension button." | ||
}, | ||
"optionResolutionTitle": { | ||
"message": "Screen Resolution", | ||
"description": "Screen Resolution affect the size of canvas for display subtitle. Lower resolution means larger font size." | ||
}, | ||
"optionBottomReserved": { | ||
"message": "Bottom Reserved Height", | ||
"description": "Reserved space at the bottom of the screen so that danmaku will not overlap subtitles." | ||
}, | ||
"optionFontFamilyTitle": { | ||
"message": "Font Family", | ||
"description": "User may chose preferred font family. Danmaku will be styled using such font family, and the width of danmaku were calculated based on the given font family. Please note that your video player may override this option." | ||
}, | ||
"optionFontSizeTitle": { | ||
"message": "Zoom Level", | ||
"description": "The font size of danmaku is set by a default value on each site. Here we only provide a general zoom option." | ||
}, | ||
"optionDanmakuSpace": { | ||
"message": "Space between danmaku", | ||
"description": "Keep some more space between each danmaku." | ||
}, | ||
"optionNormalDuration": { | ||
"message": "Duration (Normal)", | ||
"description": "How long a danmaku will be displayed on screen. (for danmaku moving from right to left)" | ||
}, | ||
"optionFixedDuration": { | ||
"message": "Duration (Fixed)", | ||
"description": "How long a danmaku will be displayed on screen. (for danmaku sticked on top or bottom)" | ||
}, | ||
"optionTolerantDelay": { | ||
"message": "Tolerant Delay", | ||
"description": "Danmaku may be delayed for better layout. This option describe the maximum delay allowed." | ||
}, | ||
"optionTextOpacity": { | ||
"message": "Opacity", | ||
"description": "Danmaku may be semitransparent." | ||
}, | ||
"optionUnitSecond": { | ||
"message": "s", | ||
"description": "The unit for measuring time." | ||
}, | ||
"optionUnitPixel": { | ||
"message": "px", | ||
"description": "The unit for measuring subtitle canvas and font size." | ||
}, | ||
"assOriginal": { | ||
"message": "Generated by ASS Danmaku based on $1", | ||
"description": "The description inserted into ASS file header to describe the source of current file." | ||
}, | ||
"downloadingTip": { | ||
"message": "[Converting]", | ||
"description": "The texts in popup menu indicating downloading status." | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{ | ||
"extensionName": { | ||
"message": "ASS Danmaku" | ||
}, | ||
"extensionDescription": { | ||
"message": "从 AcFun & bilibili 以 ASS 格式下载弹幕。在支持的网站观看视频,下载按钮将会出现在地址栏右侧。" | ||
}, | ||
"extensionButtonTitle": { | ||
"message": "下载弹幕" | ||
}, | ||
"popupNoDanmakuFound": { | ||
"message": "在支持的站点上观看视频,对应的弹幕下载会出现在这里" | ||
}, | ||
"optionResolutionTitle": { | ||
"message": "画布分辨率" | ||
}, | ||
"optionBottomReserved": { | ||
"message": "字幕区高度" | ||
}, | ||
"optionFontFamilyTitle": { | ||
"message": "字体" | ||
}, | ||
"optionFontSizeTitle": { | ||
"message": "字号比例" | ||
}, | ||
"optionDanmakuSpace": { | ||
"message": "弹幕间距" | ||
}, | ||
"optionNormalDuration": { | ||
"message": "滑动弹幕时长" | ||
}, | ||
"optionFixedDuration": { | ||
"message": "固定弹幕时长" | ||
}, | ||
"optionTolerantDelay": { | ||
"message": "弹幕最大延迟" | ||
}, | ||
"optionTextOpacity": { | ||
"message": "不透明度" | ||
}, | ||
"optionUnitSecond": { | ||
"message": "秒" | ||
}, | ||
"optionUnitPixel": { | ||
"message": "像素" | ||
}, | ||
"assOriginal": { | ||
"message": "Generated by ASS Danmaku based on $1" | ||
}, | ||
"downloadingTip": { | ||
"message": "【正在转换】" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{ | ||
"extensionName": { | ||
"message": "ASS Danmaku" | ||
}, | ||
"extensionDescription": { | ||
"message": "從 AcFun 和 bilibili 以 ASS 格式下載彈幕。在支援的站點觀看視頻,下載按鈕將出現在導覽列右側。" | ||
}, | ||
"extensionButtonTitle": { | ||
"message": "下載彈幕" | ||
}, | ||
"optionResolutionTitle": { | ||
"message": "畫布解析度" | ||
}, | ||
"optionBottomReserved": { | ||
"message": "字母區域高度" | ||
}, | ||
"optionFontFamilyTitle": { | ||
"message": "字型" | ||
}, | ||
"optionFontSizeTitle": { | ||
"message": "字型大小比例" | ||
}, | ||
"optionDanmakuSpace": { | ||
"message": "彈幕間距" | ||
}, | ||
"optionNormalDuration": { | ||
"message": "滑動彈幕期間" | ||
}, | ||
"optionFixedDuration": { | ||
"message": "固定彈幕期間" | ||
}, | ||
"optionTolerantDelay": { | ||
"message": "彈幕最大延遲" | ||
}, | ||
"optionTextOpacity": { | ||
"message": "不透明度" | ||
}, | ||
"optionUnitSecond": { | ||
"message": "秒" | ||
}, | ||
"optionUnitPixel": { | ||
"message": "像素" | ||
}, | ||
"assOriginal": { | ||
"message": "Generated by ASS Danmaku based on $1" | ||
}, | ||
"downloadingTip": { | ||
"message": "【轉換中】" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
; (function () { | ||
|
||
window.onRequest(['http://www.acfun.cn/v/ac*'], function (response, pageContext) { | ||
const html = new TextDecoder('utf-8').decode(response); | ||
const pageDom = (new DOMParser()).parseFromString(html, 'text/html'); | ||
const scriptTags = Array.from(pageDom.querySelectorAll('script')); | ||
const script = scriptTags.find(script => ( | ||
/^var pageInfo = \{.*}$/.test(script.textContent) | ||
)); | ||
const data = JSON.parse(script.textContent.match(/({.*})/)[1]); | ||
const { title } = data; | ||
const vidTitle = pageContext.metaInfo.vidTitle = pageContext.metaInfo.vidTitle || new Map(); | ||
data.videoList.forEach(({ id, title: part }) => { | ||
vidTitle.set(id, title + (part ? ' - ' + part : '')); | ||
}); | ||
}); | ||
|
||
window.onRequest(['http://danmu.aixifan.com/V4/*_*/*/*'], async function (response, pageContext, { url }) { | ||
const vid = +(url.match(/http:\/\/danmu\.aixifan\.com\/V4\/(\d+)_/) || [])[1]; | ||
const { danmaku } = window.danmaku.parser.acfun(response); | ||
if (danmaku.length === 0) return; | ||
const danmakuList = pageContext.danmakuList = pageContext.danmakuList || []; | ||
const danmakuItem = danmakuList.find(({ id }) => id === `acfun-${vid}`); | ||
if (danmakuItem) { | ||
const danmakuMap = new Map(); | ||
danmakuItem.content.concat(danmaku).forEach(danmaku => danmakuMap.set(danmaku.uuid, danmaku)); | ||
danmakuItem.content = [...danmakuMap.values()]; | ||
} else { | ||
const vidTitle = pageContext.metaInfo.vidTitle; | ||
const title = vidTitle && vidTitle.get(vid); | ||
const name = 'A' + vid + (title ? ' - ' + title : ''); | ||
danmakuList.push({ | ||
id: `acfun-${vid}`, | ||
meta: { name, url }, | ||
content: danmaku, | ||
}); | ||
} | ||
}); | ||
|
||
}()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
; (function () { | ||
|
||
const getPageTitle = async tabId => (await browser.tabs.get(tabId)).title; | ||
|
||
window.onRequest(['https://api.bilibili.com/x/player/pagelist?*'], function (response, pageContext) { | ||
const { data } = JSON.parse(new TextDecoder('utf-8').decode(response)); | ||
const { tabId } = pageContext; | ||
const cidTitle = pageContext.metaInfo.cidTitle = pageContext.metaInfo.cidTitle || new Map(); | ||
data.forEach(({ cid, part }) => { | ||
cidTitle.set(cid, (async () => { | ||
const title = await getPageTitle(tabId); | ||
const aidTitle = title.replace(/_.*$/, ''); | ||
const partTitle = part ? ' - ' + part : ''; | ||
return aidTitle + partTitle; | ||
})()); | ||
}); | ||
}); | ||
|
||
window.onRequest(['https://comment.bilibili.com/*.xml'], async function (response, pageContext, { url }) { | ||
const { cid, danmaku } = window.danmaku.parser.bilibili(response); | ||
if (danmaku.length === 0) return; | ||
const { tabId } = pageContext; | ||
const cidTitle = pageContext.metaInfo.cidTitle; | ||
const title = await (cidTitle && cidTitle.get(cid) || getPageTitle(tabId)); | ||
const name = 'B' + cid + (title ? ' - ' + title : ''); | ||
const danmakuList = pageContext.danmakuList = pageContext.danmakuList || []; | ||
danmakuList.push({ | ||
id: `bilibili-${cid}`, | ||
meta: { name, url }, | ||
content: danmaku, | ||
}); | ||
}); | ||
|
||
}()); |
Oops, something went wrong.