Skip to content

Shorten all extension names automatically #153

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 24, 2024
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
3 changes: 1 addition & 2 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export default antfu({
svelte: true,
stylistic: {
indent: 'tab',
semi: 'always',
},
languageOptions: {
globals: {
Expand All @@ -13,9 +14,7 @@ export default antfu({
rules: {
'no-self-assign': 'off',
'no-console': 'off',
'import/order': 'off',
'jsonc/object-curly-spacing': 'off',
'style/semi': ['error', 'always'],
'svelte/html-quotes': [
'error',
{
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

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

14 changes: 13 additions & 1 deletion source/extension.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
const chromeWebStoreUrl = `https://chrome.google.com/webstore/detail/${id}`;
const edgeWebStoreUrl = `https://microsoftedge.microsoft.com/addons/detail/${id}`;
const url = generateHomeURL();
// The browser will still fill the "short name" with "name" if missing
const realName = trimName(shortName ?? name);

function generateHomeURL() {
if (installType !== 'normal') {
Expand All @@ -28,6 +30,16 @@
: chromeWebStoreUrl;
}

// https://github.com/hankxdev/one-click-extensions-manager/issues/152
function trimName(name) {
return name
.replace(/[-:—|].+$/, '')
.replace(
/(extension|chrome extension|browser extension|for chrome|for google chrome)$/i,
'',
);
}

function toggleExtension() {
const wasEnabled = enabled;

Expand Down Expand Up @@ -65,7 +77,7 @@
on:click={toggleExtension}
on:contextmenu
>
<img alt="" src={getIcon(icons, 16)} />{shortName ?? name}
<img alt="" src={getIcon(icons, 16)} />{realName}
</button>
{#if optionsUrl && enabled}
<a href={optionsUrl} title={getI18N('gotoOpt')} on:click={openInTab}>
Expand Down
Loading