Skip to content

Commit

Permalink
Merge branch 'preview-fixes'
Browse files Browse the repository at this point in the history
  • Loading branch information
the1812 committed May 7, 2022
2 parents b8343ed + e03c76e commit 8b0ad95
Show file tree
Hide file tree
Showing 12 changed files with 88 additions and 38 deletions.
8 changes: 0 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,6 @@
"vue": "^2.6.11",
"vue-fragment": "^1.5.2"
},
"repository": {
"type": "git",
"url": "git+https://github.com/the1812/Bilibili-Evolved.git"
},
"bugs": {
"url": "https://github.com/the1812/Bilibili-Evolved/issues"
},
"homepage": "https://github.com/the1812/Bilibili-Evolved#readme",
"keywords": [
"userscript",
"bilibili",
Expand Down
2 changes: 1 addition & 1 deletion registry/dist/components/feeds/unfold.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion registry/lib/components/feeds/unfold/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const component: ComponentMetadata = {
const { forEachFeedsCard } = await import('@/components/feeds/api')
forEachFeedsCard({
added: card => {
const foldButton = dq(card.element, '.fold-hoverable') as HTMLElement
const foldButton = dq(card.element, '.fold-hoverable, .bili-dyn-item-fold') as HTMLElement
foldButton?.click()
},
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ body.remove-game-match-module #reportFirst3,
.home-content .ad-panel,
.recommend-list .rec-list > :not(.video-page-card),
.eva-extension-area,
.eva-banner {
.eva-banner,
.video-ad-creative-card,
.bili-dyn-home--member .bili-dyn-ads {
display: none !important;
}
.recommend-list .rec-list > :not(.video-page-card) + .video-page-card {
Expand Down
4 changes: 2 additions & 2 deletions registry/lib/components/utils/url-params-clean/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { registerAndGetData } from '@/plugins/data'
import { ComponentMetadata } from '@/components/types'
import { isNotHtml, matchPattern } from '@/core/utils'
import { isIframe, isNotHtml, matchPattern } from '@/core/utils'
import { useScopedConsole } from '@/core/utils/log'

const displayName = '网址参数清理'
const console = useScopedConsole(displayName)
const entry = async () => {
if (isNotHtml()) {
if (isNotHtml() || isIframe()) {
return
}
const builtInNoClean = [
Expand Down
5 changes: 2 additions & 3 deletions src/client/common.meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
"*://t.bilibili.com/h5/dynamic/specification",
"*://bbq.bilibili.com/*",
"*://message.bilibili.com/pages/nav/header_sync",
"*://s1.hdslb.com/bfs/seed/jinkela/short/cols/iframe.html"
"*://s1.hdslb.com/bfs/seed/jinkela/short/cols/iframe.html",
"*://open-live.bilibili.com/*"
],
"run-at": "document-start",
"supportURL": "https://github.com/the1812/Bilibili-Evolved/issues",
"homepage": "https://github.com/the1812/Bilibili-Evolved",
"grant": [
"unsafeWindow",
"GM_getValue",
Expand Down
1 change: 1 addition & 0 deletions src/components/feeds/api/manager/v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const feedsCardTypeMap = {
DynamicTypePgc: feedsCardTypes.bangumi,
DynamicTypeArticle: feedsCardTypes.column,
DynamicTypeMusic: feedsCardTypes.audio,
DynamicTypeLiveRcmd: feedsCardTypes.liveRecord,
}

const combineText = (...texts: string[]) => texts.filter(it => Boolean(it)).join('\n').trim()
Expand Down
2 changes: 1 addition & 1 deletion src/components/settings-panel/ComponentDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<div class="component-detail-internal-data">
<div v-if="componentData.commitHash" class="component-detail-internal-data-row">
<div class="internal-name">
Commit: {{ componentData.commitHash.substr(0, 9) }}
Commit: {{ componentData.commitHash.substring(0, 9) }}
</div>
</div>
<div class="component-detail-internal-data-row">
Expand Down
14 changes: 13 additions & 1 deletion src/components/settings-panel/sub-pages/AboutPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
Commit Hash: {{ meta.compilationInfo.commitHash.substring(0, 8) }}
</div> -->
</div>
<div class="script-links">
<div v-if="feedbackSupported" class="script-links">
<a target="_blank" href="https://github.com/the1812/Bilibili-Evolved" class="homepage script-link">
<VButton>
<VIcon icon="mdi-home-outline" :size="20" />
Expand Down Expand Up @@ -72,6 +72,17 @@ import {
} from '@/ui'
import { AboutPageAction, aboutPageActions } from './about-page'
const feedbackSupported = (() => {
const namespace = GM_info.scriptMetaStr.match(/@namespace\s*(.+)/)
if (!namespace || !namespace[1]) {
return true
}
if (namespace[1].includes('greasyfork')) {
return false
}
return true
})()
export default Vue.extend({
components: {
VButton,
Expand All @@ -81,6 +92,7 @@ export default Vue.extend({
return {
meta,
aboutPageActions,
feedbackSupported,
}
},
methods: {
Expand Down
2 changes: 1 addition & 1 deletion src/components/video/ass-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const convertHexColorForStyle = (hexColor: string, opacity = 1) => {
}
const round = (number: number) => {
const [integer, decimal = '00'] = String(number).split('.')
return `${integer.padStart(2, '0')}.${decimal.substr(0, 2).padEnd(2, '0')}`
return `${integer.padStart(2, '0')}.${decimal.substring(0, 2).padEnd(2, '0')}`
}
const secondsToTime = (seconds: number) => {
let hours = 0
Expand Down
14 changes: 9 additions & 5 deletions src/core/utils/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,10 @@ export const useScopedConsole = (config: ScopedConsoleConfig | string) => {
lastScopedData ? prependConfig.color : firstColor
) ?? specialPalette.default
const textColor = '#fff'
const leadingWhitespace = lastScopedData ? ['%c '] : ['%c']
const currentScopedData: ScopedData = {
badgeNames: [...(lastScopedData?.badgeNames ?? []), `%c${prependConfig.name}`],
badgeValues: [...(lastScopedData?.badgeValues ?? []), `background-color: ${backgroundColor}; color: ${textColor}; padding: 2px 4px; border-radius: 4px; margin-left: ${lastScopedData ? 6 : 0}px`],
badgeNames: [...(lastScopedData?.badgeNames ?? []), ...leadingWhitespace, `%c${prependConfig.name}`],
badgeValues: [...(lastScopedData?.badgeValues ?? []), '', `background-color: ${backgroundColor}; color: ${textColor}; padding: 2px 4px; border-radius: 4px;`],
original: lastScopedData?.original ?? target,
}
const rootTarget = currentScopedData.original
Expand All @@ -95,15 +96,18 @@ export const useScopedConsole = (config: ScopedConsoleConfig | string) => {
}
const { before: beforeCall, after: afterCall } = getHook(ScopedConsoleCallHook)
beforeCall(hookPayload)
afterCall(hookPayload)
let returnValue: any
if (groupCounter === 0) {
return rootTarget.apply(this, [
returnValue = rootTarget.apply(this, [
currentScopedData.badgeNames.join(''),
...currentScopedData.badgeValues,
...args,
])
} else {
returnValue = rootTarget.apply(this, args)
}
return rootTarget.apply(this, args)
afterCall(hookPayload)
return returnValue
}
patchedLog[ScopedConsoleSymbol] = currentScopedData
return patchedLog
Expand Down
68 changes: 54 additions & 14 deletions src/core/utils/title.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,45 @@
import { dq } from '../utils'
import { getGeneralSettings } from '../settings'
import { formatFilename } from './formatters'
import { descendingSort } from './sort'

type StringMap = Record<string, string>
const tokenSplit = (format: string) => {
let startIndex = 0
let depth = 0
const tokens: string[] = []
format.split('').forEach((char, index) => {
if (char === '[') {
if (depth === 0) {
tokens.push(format.substring(startIndex, index))
startIndex = index
} else {
depth++
}
}
if (char === ']') {
if (depth === 0) {
tokens.push(format.substring(startIndex, index + 1))
startIndex = index + 1
} else {
depth--
}
}
})
if (startIndex < format.length) {
tokens.push(format.substring(startIndex))
}
return tokens
}
export const formatTitle = (
format: string,
includesPageTitle = true,
extraData: StringMap = {},
extraVariables: StringMap = {},
) => {
const now = new Date()
const data: StringMap = {
const builtInVariables: StringMap = {
title: document.title
.replace(/第[0-9]*[一二三四五六七八九十百千]*[集话]-[^-]+-[^-]+-[^-]+在线观看-bilibili-哔哩哔哩$/, '')
.replace(/-[^-]+-[^-]+-[^-]+在线观看-bilibili-哔哩哔哩$/, '')
.replace(/-[^-]+-[^-]+在线观看-bilibili-哔哩哔哩$/, '')
.replace(/:([^:]+?)_.+?_bilibili_哔哩哔哩$/, '')
.replace(/_哔哩哔哩_bilibili$/, '')
Expand Down Expand Up @@ -45,17 +73,29 @@ export const formatTitle = (
h: now.getHours().toString().padStart(2, '0'),
m: now.getMinutes().toString().padStart(2, '0'),
s: now.getSeconds().toString().padStart(2, '0'),
ms: now.getMilliseconds().toString().substr(0, 3),
ms: now.getMilliseconds().toString().substring(0, 3),
}
const variables = {
...builtInVariables,
...extraVariables,
}
Object.assign(data, extraData)
const filename = Object.keys(data)
.sort(descendingSort(it => it.length))
.reduce((result, name) => result.replace(
new RegExp(`\\[([^\\[\\]]*?)${name}([^\\[\\]]*?)\\]`, 'g'),
data[name] ? `$1${data[name]}$2` : '',
), format)
return formatFilename(filename, ' ')
const tokens = tokenSplit(format)
const processedTokens = tokens.map(token => {
if (!token.startsWith('[') || !token.endsWith(']')) {
return token
}
for (const [name, value] of Object.entries(variables)) {
const regex = new RegExp(`^\\[([^\\[\\]]*?)${name}([^\\[\\]]*?)\\]$`)
const match = token.match(regex)
if (match && Boolean(value)) {
return `${match[1] ?? ''}${value}${match[2] ?? ''}`
}
}
return ''
})
const finalTitle = processedTokens.join('')
return formatFilename(finalTitle, ' ')
}
export const getFriendlyTitle = (includesPageTitle = true, extraData: StringMap = {}) => (
formatTitle(getGeneralSettings().filenameFormat, includesPageTitle, extraData)
export const getFriendlyTitle = (includesPageTitle = true, extraVariables: StringMap = {}) => (
formatTitle(getGeneralSettings().filenameFormat, includesPageTitle, extraVariables)
)

0 comments on commit 8b0ad95

Please sign in to comment.