Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 3,
"name": "__MSG_extName__",
"description": "__MSG_extDescription__",
"version": "0.12.3",
"version": "0.13.0",
"default_locale": "en",
"icons": {
"128": "icon128.png"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "selection-command",
"version": "0.12.3",
"version": "0.13.0",
"author": "ujiro99",
"license": "MIT",
"private": true,
Expand Down
2 changes: 1 addition & 1 deletion public/_locales/de/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@
"message": "Wiederherstellen"
},
"Option_RestoreFromBackup_legacy": {
"message": "Legacy-Migration"
"message": "Backup aktualisieren"
},
"Option_RestoreFromBackup_daily": {
"message": "Tägliches Backup"
Expand Down
2 changes: 1 addition & 1 deletion public/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@
"message": "Restore"
},
"Option_RestoreFromBackup_legacy": {
"message": "Legacy Migration"
"message": "Update Backup"
},
"Option_RestoreFromBackup_daily": {
"message": "Daily Backup"
Expand Down
2 changes: 1 addition & 1 deletion public/_locales/es/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@
"message": "Restaurar"
},
"Option_RestoreFromBackup_legacy": {
"message": "Migración Heredada"
"message": "Actualizar Respaldo"
},
"Option_RestoreFromBackup_daily": {
"message": "Respaldo Diario"
Expand Down
2 changes: 1 addition & 1 deletion public/_locales/fr/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@
"message": "Restaurer"
},
"Option_RestoreFromBackup_legacy": {
"message": "Migration Héritée"
"message": "Mettre à jour la sauvegarde"
},
"Option_RestoreFromBackup_daily": {
"message": "Sauvegarde Quotidienne"
Expand Down
2 changes: 1 addition & 1 deletion public/_locales/hi/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@
"message": "पुनर्स्थापना"
},
"Option_RestoreFromBackup_legacy": {
"message": "लेगेसी माइग्रेशन"
"message": "बैकअप अपडेट करें"
},
"Option_RestoreFromBackup_daily": {
"message": "दैनिक बैकअप"
Expand Down
2 changes: 1 addition & 1 deletion public/_locales/id/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@
"message": "Pulihkan"
},
"Option_RestoreFromBackup_legacy": {
"message": "Migrasi Warisan"
"message": "Perbarui Cadangan"
},
"Option_RestoreFromBackup_daily": {
"message": "Cadangan Harian"
Expand Down
2 changes: 1 addition & 1 deletion public/_locales/it/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@
"message": "Ripristina"
},
"Option_RestoreFromBackup_legacy": {
"message": "Migrazione Legacy"
"message": "Aggiorna Backup"
},
"Option_RestoreFromBackup_daily": {
"message": "Backup Giornaliero"
Expand Down
2 changes: 1 addition & 1 deletion public/_locales/ja/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@
"message": "復元"
},
"Option_RestoreFromBackup_legacy": {
"message": "レガシー移行"
"message": "更新時バックアップ"
},
"Option_RestoreFromBackup_daily": {
"message": "日次バックアップ"
Expand Down
2 changes: 1 addition & 1 deletion public/_locales/ko/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@
"message": "복원"
},
"Option_RestoreFromBackup_legacy": {
"message": "레거시 마이그레이션"
"message": "백업 업데이트"
},
"Option_RestoreFromBackup_daily": {
"message": "일간 백업"
Expand Down
2 changes: 1 addition & 1 deletion public/_locales/ms/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@
"message": "Pulihkan"
},
"Option_RestoreFromBackup_legacy": {
"message": "Migrasi Legasi"
"message": "Kemas Kini Sandaran"
},
"Option_RestoreFromBackup_daily": {
"message": "Sandaran Harian"
Expand Down
2 changes: 1 addition & 1 deletion public/_locales/pt_BR/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@
"message": "Restaurar"
},
"Option_RestoreFromBackup_legacy": {
"message": "Migração Legada"
"message": "Atualizar Backup"
},
"Option_RestoreFromBackup_daily": {
"message": "Backup Diário"
Expand Down
2 changes: 1 addition & 1 deletion public/_locales/pt_PT/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@
"message": "Restaurar"
},
"Option_RestoreFromBackup_legacy": {
"message": "Migração Legada"
"message": "Atualizar Cópia de Segurança"
},
"Option_RestoreFromBackup_daily": {
"message": "Cópia de Segurança Diária"
Expand Down
2 changes: 1 addition & 1 deletion public/_locales/ru/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@
"message": "Восстановить"
},
"Option_RestoreFromBackup_legacy": {
"message": "Унаследованная миграция"
"message": "Обновить резервную копию"
},
"Option_RestoreFromBackup_daily": {
"message": "Ежедневная резервная копия"
Expand Down
2 changes: 1 addition & 1 deletion public/_locales/zh_CN/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@
"message": "恢复"
},
"Option_RestoreFromBackup_legacy": {
"message": "传统迁移"
"message": "更新备份"
},
"Option_RestoreFromBackup_daily": {
"message": "每日备份"
Expand Down
2 changes: 1 addition & 1 deletion src/action/addPageRule.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Ipc, BgCommand } from '@/services/ipc'
import { Ipc, BgCommand } from "@/services/ipc"

export const AddPageRule = {
async execute() {
Expand Down
26 changes: 13 additions & 13 deletions src/action/api.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Ipc, BgCommand } from '@/services/ipc'
import { sleep, toUrl, isValidString } from '@/lib/utils'
import type { ExecuteCommandParams, ApiCommand } from '@/types'
import { OPEN_MODE, ExecState, SPACE_ENCODING } from '@/const'
import { Ipc, BgCommand } from "@/services/ipc"
import { sleep, toUrl, isValidString } from "@/lib/utils"
import type { ExecuteCommandParams, ApiCommand } from "@/types"
import { OPEN_MODE, ExecState, SPACE_ENCODING } from "@/const"

const isApiCommand = (command: any): command is ApiCommand => {
return command.OpenMode === OPEN_MODE.API
Expand All @@ -16,28 +16,28 @@ export const Api = {
changeState(ExecState.EXECUTING)

if (!isValidString(command.searchUrl)) {
console.error('searchUrl is not valid.')
console.error("searchUrl is not valid.")
return
}

if (!isApiCommand(command)) {
console.error('command is not for Api.')
console.error("command is not for Api.")
return
}

// Get current URL and title
let pageUrl = ''
let pageTitle = ''
let pageUrl = ""
let pageTitle = ""
try {
const currentTab = await chrome.tabs.query({
active: true,
})
if (currentTab[0]) {
pageUrl = currentTab[0].url ?? ''
pageTitle = currentTab[0].title ?? ''
pageUrl = currentTab[0].url ?? ""
pageTitle = currentTab[0].title ?? ""
}
} catch (error) {
console.warn('Failed to get current tab info:', error)
console.warn("Failed to get current tab info:", error)
}

Ipc.send(BgCommand.execApi, {
Expand All @@ -54,10 +54,10 @@ export const Api = {
})
.then(({ ok, res }) => {
if (ok) {
changeState(ExecState.SUCCESS, 'Success!')
changeState(ExecState.SUCCESS, "Success!")
} else {
console.error(res)
changeState(ExecState.FAIL, 'Failed...')
changeState(ExecState.FAIL, "Failed...")
}
return sleep(1500)
})
Expand Down
16 changes: 8 additions & 8 deletions src/action/background.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { OPEN_MODE_BG } from '@/const'
import { Popup } from './popup'
import { Window } from './window'
import { Tab } from './tab'
import { Api } from './api'
import { PageAction } from './pageAction'
import { executeAction } from './executor'
import type { ExecuteCommandParams } from '@/types'
import { OPEN_MODE_BG } from "@/const"
import { Popup } from "./popup"
import { Window } from "./window"
import { Tab } from "./tab"
import { Api } from "./api"
import { PageAction } from "./pageAction"
import { executeAction } from "./executor"
import type { ExecuteCommandParams } from "@/types"

export const actionsForBackground = {
[OPEN_MODE_BG.POPUP]: Popup,
Expand Down
28 changes: 14 additions & 14 deletions src/action/copy.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { sleep, isEmpty } from '@/lib/utils'
import { getSelectionText } from '@/services/dom'
import type { CopyCommand, ExecuteCommandParams } from '@/types'
import { OPEN_MODE, ExecState } from '@/const'
import { sleep, isEmpty } from "@/lib/utils"
import { getSelectionText } from "@/services/dom"
import type { CopyCommand, ExecuteCommandParams } from "@/types"
import { OPEN_MODE, ExecState } from "@/const"

const isCopyCommand = (command: any): command is CopyCommand => {
return command.openMode === OPEN_MODE.COPY
}

async function setClipboard(text: string) {
const type = 'text/plain'
const type = "text/plain"
const blob = new Blob([text], { type })
const data = [new ClipboardItem({ [type]: blob })]
await navigator.clipboard.write(data)
Expand All @@ -22,33 +22,33 @@ export const Copy = {
changeState = () => {},
}: ExecuteCommandParams) {
if (!isCopyCommand(command)) {
console.error('command is not for Copy.')
console.error("command is not for Copy.")
return
}

changeState(ExecState.EXECUTING)
const currentText = getSelectionText()

let mode = command.copyOption ?? 'default'
let mode = command.copyOption ?? "default"
if (useSecondary) {
if (mode === 'default') {
mode = 'text'
if (mode === "default") {
mode = "text"
} else {
mode = 'default'
mode = "default"
}
}

if (mode === 'default') {
if (mode === "default") {
if (isEmpty(currentText)) {
await setClipboard(selectionText)
} else {
document.execCommand('copy')
document.execCommand("copy")
}
} else if (mode === 'text') {
} else if (mode === "text") {
await setClipboard(selectionText)
}

changeState(ExecState.SUCCESS, 'Copied!')
changeState(ExecState.SUCCESS, "Copied!")
await sleep(500)
changeState(ExecState.NONE)
},
Expand Down
8 changes: 4 additions & 4 deletions src/action/executor.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ExecuteCommandParams } from '@/types'
import { OPEN_MODE } from '@/const'
import { sendEvent, ANALYTICS_EVENTS } from '@/services/analytics'
import type { ExecuteCommandParams } from "@/types"
import { OPEN_MODE } from "@/const"
import { sendEvent, ANALYTICS_EVENTS } from "@/services/analytics"

export async function executeAction({
actions,
Expand All @@ -15,7 +15,7 @@ export async function executeAction({
let mode = command.openMode as OPEN_MODE
if (
useSecondary &&
'openModeSecondary' in command &&
"openModeSecondary" in command &&
command.openModeSecondary
) {
mode = command.openModeSecondary
Expand Down
34 changes: 17 additions & 17 deletions src/action/getStyles.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ExecuteCommandParams } from '@/types'
import { TextStyle } from '@/components/result/TextStyle'
import type { ExecuteCommandParams } from "@/types"
import { TextStyle } from "@/components/result/TextStyle"

export const GetStyles = {
async execute({ target }: ExecuteCommandParams) {
Expand All @@ -14,23 +14,23 @@ export const GetStyles = {
}

const CANVAS_OPTIONS = {
fillStyle: 'rgb(0,0,0)',
fillStyle: "rgb(0,0,0)",
height: 50,
size: '40px',
textBaseline: 'top',
size: "40px",
textBaseline: "top",
width: 600,
}

function getFontOption(css: FontCSS) {
return `${css.fontStyle} ${css.fontWeight} ${CANVAS_OPTIONS.size} ${css.fontFamily}`
}

function getCanvasData(css: FontCSS, text = 'abcdefghijklmnopqrstuvwxyz') {
const canvas = document.createElement('canvas')
function getCanvasData(css: FontCSS, text = "abcdefghijklmnopqrstuvwxyz") {
const canvas = document.createElement("canvas")
canvas.width = CANVAS_OPTIONS.width
canvas.height = CANVAS_OPTIONS.height

const ctx = canvas.getContext('2d')
const ctx = canvas.getContext("2d")
if (!ctx) return null

Object.assign(ctx, CANVAS_OPTIONS)
Expand All @@ -39,7 +39,7 @@ function getCanvasData(css: FontCSS, text = 'abcdefghijklmnopqrstuvwxyz') {
ctx.fillText(text, 0, 0)

return canvas
.getContext('2d')
.getContext("2d")
?.getImageData(0, 0, CANVAS_OPTIONS.width, CANVAS_OPTIONS.height).data
}

Expand Down Expand Up @@ -68,11 +68,11 @@ const getActiveFont = (css: FontCSS) => {
for (let f = 0; f < stack.length; f++) {
const serifStyle = {
...css,
fontFamily: stack[f] + ', serif',
fontFamily: stack[f] + ", serif",
}
const sansSerifStyle = {
...css,
fontFamily: stack[f] + ', sans-serif',
fontFamily: stack[f] + ", sans-serif",
}

if (
Expand All @@ -90,11 +90,11 @@ function getFontCSS(element: HTMLElement): FontCSS {

return {
fontFamily: getActiveFont(computed),
fontWeight: computed.getPropertyValue('font-weight') || 'normal',
fontStyle: computed.getPropertyValue('font-style') || 'normal',
fontSize: computed.getPropertyValue('font-size'),
color: computed.getPropertyValue('color'),
lineHeight: computed.getPropertyValue('line-height'),
letterSpacing: computed.getPropertyValue('letter-spacing'),
fontWeight: computed.getPropertyValue("font-weight") || "normal",
fontStyle: computed.getPropertyValue("font-style") || "normal",
fontSize: computed.getPropertyValue("font-size"),
color: computed.getPropertyValue("color"),
lineHeight: computed.getPropertyValue("line-height"),
letterSpacing: computed.getPropertyValue("letter-spacing"),
}
}
Loading