Files
RuoYi-Vue/browser-extension/multi-platform-publisher-1.1.17/content/bilibili.js

70 lines
2.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

(() => {
const config = {
platform: 'bilibili',
platformName: 'B站',
fillAfterUploadSettled: true,
uploadSettleTimeout: 30 * 60 * 1000,
fillDelay: 1000,
videoModeLabels: [],
imageModeLabels: [],
uploadSelectors: [
'.upload-btn input[type="file"]',
'.upload-wrapper input[type="file"]',
'input[type="file"][accept*="video"]',
'input[type="file"][accept*="mp4"]',
'input[type="file"]'
],
uploadDropZoneSelectors: [
'.upload-btn',
'.upload-wrapper',
'[class*="upload"] [class*="drag"]'
],
videoInputSelectors: [
'.upload-btn input[type="file"]',
'.upload-wrapper input[type="file"]',
'input[type="file"][accept*="video"]',
'input[type="file"][accept*="mp4"]'
],
imageInputSelectors: [],
coverInputSelectors: [
'[class*="cover"] input[type="file"][accept*="image"]',
'[class*="cover"] input[type="file"]',
'[class*="poster"] input[type="file"][accept*="image"]'
],
titleSelectors: [
'input[placeholder*="稿件标题"]',
'input[placeholder*="视频标题"]',
'input[placeholder*="标题"]',
'input[maxlength="80"]',
'[class*="title"] input[type="text"]'
],
contentSelectors: [
'textarea[placeholder*="视频简介"]',
'textarea[placeholder*="稿件简介"]',
'textarea[placeholder*="简介"]',
'[contenteditable="true"][data-placeholder*="简介"]',
'[contenteditable="true"][data-placeholder*="描述"]',
'.ql-editor[contenteditable="true"]',
'[class*="desc"] [contenteditable="true"]',
'[class*="desc"] textarea'
],
progressSelectors: [
'.upload-progress',
'.bcc-progress',
'[class*="upload"] [class*="progress"]',
'[role="progressbar"]'
],
successTexts: [/^投稿成功[!!。]?$/, /^发布成功[!!。]?$/, /^稿件投递成功[!!。]?$/],
failureTexts: [/^投稿失败/, /^发布失败/, /^稿件投递失败/]
}
chrome.runtime.onMessage.addListener(message => {
if (message && message.type === 'RUN_PUBLISH') {
globalThis.YidaimaPublisher.run(config, message.payload)
} else if (message && message.type === 'WATCH_PUBLISH_OUTCOME') {
globalThis.YidaimaPublisher.watch(config, message.payload)
}
})
chrome.runtime.sendMessage({ type: 'PLATFORM_READY', platform: config.platform })
})()