chore(lint): enforce 2-space indent & add gpg pre-commit hook

This commit is contained in:
2026-03-04 02:45:53 +00:00
parent b98a14950c
commit 10286c2924
7 changed files with 135 additions and 118 deletions

View File

@@ -31,7 +31,7 @@ export function useExtension() {
extensionCheckInterval = setInterval(() => {
window.postMessage({ type: 'TOOLS_APP_PING' }, '*')
if (Date.now() - lastPongTime > TIMEOUT_THRESHOLD) {
isExtensionReady.value = false
isExtensionReady.value = false
}
}, PING_INTERVAL)
}

View File

@@ -1,115 +1,115 @@
import { useLocalStorage } from './useLocalStorage'
export function useUrlCleaner() {
const cleanedHistory = useLocalStorage('url-cleaner-history', [])
const isWatchEnabled = useLocalStorage('url-cleaner-watch-enabled', false)
const cleanedHistory = useLocalStorage('url-cleaner-history', [])
const isWatchEnabled = useLocalStorage('url-cleaner-watch-enabled', false)
const defaultExceptions = [
{ id: 'yt', domainPattern: '*.youtube.com', keepParams: ['v', 't'], keepHash: false, keepAllParams: false, isEnabled: true, isDefault: true },
{ id: 'yt-short', domainPattern: 'youtu.be', keepParams: ['t'], keepHash: false, keepAllParams: false, isEnabled: true, isDefault: true }
]
const exceptions = useLocalStorage('url-cleaner-exceptions', defaultExceptions)
const defaultExceptions = [
{ id: 'yt', domainPattern: '*.youtube.com', keepParams: ['v', 't'], keepHash: false, keepAllParams: false, isEnabled: true, isDefault: true },
{ id: 'yt-short', domainPattern: 'youtu.be', keepParams: ['t'], keepHash: false, keepAllParams: false, isEnabled: true, isDefault: true }
]
const exceptions = useLocalStorage('url-cleaner-exceptions', defaultExceptions)
const matchDomain = (pattern, domain) => {
// Escape regex chars except *
const regexString = '^' + pattern.replace(/[.+^${}()|[\]\\]/g, '\\$&').replace(/\*/g, '.*') + '$'
return new RegExp(regexString, 'i').test(domain)
}
const matchDomain = (pattern, domain) => {
// Escape regex chars except *
const regexString = '^' + pattern.replace(/[.+^${}()|[\]\\]/g, '\\$&').replace(/\*/g, '.*') + '$'
return new RegExp(regexString, 'i').test(domain)
}
const processUrl = (text, autoClipboard = false, writeClipboardFn = null) => {
try {
// Basic URL validation
if (!text.match(/^https?:\/\//i)) {
if (autoClipboard) return text
const processUrl = (text, autoClipboard = false, writeClipboardFn = null) => {
try {
// Basic URL validation
if (!text.match(/^https?:\/\//i)) {
if (autoClipboard) return text
}
const originalLength = text.length
let cleanedUrl = text
try {
const urlObj = new URL(text)
const hostname = urlObj.hostname
const matchedRule = exceptions.value.find(rule =>
rule.isEnabled && matchDomain(rule.domainPattern, hostname)
)
if (matchedRule) {
if (!matchedRule.keepAllParams) {
const params = new URLSearchParams(urlObj.search)
const keys = Array.from(params.keys())
for (const key of keys) {
if (!matchedRule.keepParams.includes(key)) {
params.delete(key)
}
}
urlObj.search = params.toString()
}
const originalLength = text.length
let cleanedUrl = text
try {
const urlObj = new URL(text)
const hostname = urlObj.hostname
const matchedRule = exceptions.value.find(rule =>
rule.isEnabled && matchDomain(rule.domainPattern, hostname)
)
if (matchedRule) {
if (!matchedRule.keepAllParams) {
const params = new URLSearchParams(urlObj.search)
const keys = Array.from(params.keys())
for (const key of keys) {
if (!matchedRule.keepParams.includes(key)) {
params.delete(key)
}
}
urlObj.search = params.toString()
}
if (!matchedRule.keepHash) {
urlObj.hash = ''
}
} else {
if (urlObj.search || urlObj.hash) {
urlObj.search = ''
urlObj.hash = ''
}
}
cleanedUrl = urlObj.toString()
} catch (e) {
return text
}
if (cleanedUrl === text && autoClipboard) {
return text
}
const newLength = cleanedUrl.length
const savedChars = originalLength - newLength
const savedPercent = originalLength > 0 ? Math.round((savedChars / originalLength) * 100) : 0
const entry = {
id: Date.now(),
original: text,
cleaned: cleanedUrl,
savedPercent,
timestamp: new Date().toLocaleTimeString()
}
cleanedHistory.value.unshift(entry)
if (cleanedHistory.value.length > 50) {
cleanedHistory.value.pop()
}
if (autoClipboard && savedChars > 0 && writeClipboardFn) {
writeClipboardFn(cleanedUrl)
}
return cleanedUrl
} catch (e) {
console.error('Error processing URL:', e)
return text
if (!matchedRule.keepHash) {
urlObj.hash = ''
}
} else {
if (urlObj.search || urlObj.hash) {
urlObj.search = ''
urlObj.hash = ''
}
}
}
const removeEntry = (id) => {
cleanedHistory.value = cleanedHistory.value.filter(item => item.id !== id)
}
cleanedUrl = urlObj.toString()
} catch (e) {
return text
}
const clearHistory = () => {
cleanedHistory.value = []
}
if (cleanedUrl === text && autoClipboard) {
return text
}
return {
cleanedHistory,
isWatchEnabled,
exceptions,
defaultExceptions,
processUrl,
removeEntry,
clearHistory
const newLength = cleanedUrl.length
const savedChars = originalLength - newLength
const savedPercent = originalLength > 0 ? Math.round((savedChars / originalLength) * 100) : 0
const entry = {
id: Date.now(),
original: text,
cleaned: cleanedUrl,
savedPercent,
timestamp: new Date().toLocaleTimeString()
}
cleanedHistory.value.unshift(entry)
if (cleanedHistory.value.length > 50) {
cleanedHistory.value.pop()
}
if (autoClipboard && savedChars > 0 && writeClipboardFn) {
writeClipboardFn(cleanedUrl)
}
return cleanedUrl
} catch (e) {
console.error('Error processing URL:', e)
return text
}
}
const removeEntry = (id) => {
cleanedHistory.value = cleanedHistory.value.filter(item => item.id !== id)
}
const clearHistory = () => {
cleanedHistory.value = []
}
return {
cleanedHistory,
isWatchEnabled,
exceptions,
defaultExceptions,
processUrl,
removeEntry,
clearHistory
}
}

View File

@@ -19,7 +19,7 @@ const Ripple = {
// Allow custom color via directive value
if (binding.value && typeof binding.value === 'string') {
circle.style.backgroundColor = binding.value;
circle.style.backgroundColor = binding.value;
}
el.appendChild(circle);

View File

@@ -212,6 +212,12 @@ body {
box-sizing: border-box;
}
::placeholder {
color: var(--text-muted);
opacity: 1;
/* Override Firefox default opacity */
}
.tool-textarea {
font-family: monospace;
resize: none;

View File

@@ -1,22 +1,22 @@
import QRCode from 'qrcode'
self.onmessage = async (e) => {
const { id, text, ecc } = e.data
const { id, text, ecc } = e.data
if (!text) {
self.postMessage({ id, svgContent: '' })
return
}
if (!text) {
self.postMessage({ id, svgContent: '' })
return
}
try {
const svgContent = await QRCode.toString(text, {
type: 'svg',
errorCorrectionLevel: ecc,
margin: 1,
})
try {
const svgContent = await QRCode.toString(text, {
type: 'svg',
errorCorrectionLevel: ecc,
margin: 1,
})
self.postMessage({ id, svgContent })
} catch (err) {
self.postMessage({ id, error: err.message })
}
self.postMessage({ id, svgContent })
} catch (err) {
self.postMessage({ id, error: err.message })
}
}