Skip to content

Commit d0f63e3

Browse files
authored
Shorten all extension names automatically (#153)
1 parent f4baf53 commit d0f63e3

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

eslint.config.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export default antfu({
44
svelte: true,
55
stylistic: {
66
indent: 'tab',
7+
semi: 'always',
78
},
89
languageOptions: {
910
globals: {
@@ -13,9 +14,7 @@ export default antfu({
1314
rules: {
1415
'no-self-assign': 'off',
1516
'no-console': 'off',
16-
'import/order': 'off',
1717
'jsonc/object-curly-spacing': 'off',
18-
'style/semi': ['error', 'always'],
1918
'svelte/html-quotes': [
2019
'error',
2120
{

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

source/extension.svelte

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
const chromeWebStoreUrl = `https://chrome.google.com/webstore/detail/${id}`;
1818
const edgeWebStoreUrl = `https://microsoftedge.microsoft.com/addons/detail/${id}`;
1919
const url = generateHomeURL();
20+
// The browser will still fill the "short name" with "name" if missing
21+
const realName = trimName(shortName ?? name);
2022
2123
function generateHomeURL() {
2224
if (installType !== 'normal') {
@@ -28,6 +30,16 @@
2830
: chromeWebStoreUrl;
2931
}
3032
33+
// https://github.com/hankxdev/one-click-extensions-manager/issues/152
34+
function trimName(name) {
35+
return name
36+
.replace(/[-:—|].+$/, '')
37+
.replace(
38+
/(extension|chrome extension|browser extension|for chrome|for google chrome)$/i,
39+
'',
40+
);
41+
}
42+
3143
function toggleExtension() {
3244
const wasEnabled = enabled;
3345
@@ -65,7 +77,7 @@
6577
on:click={toggleExtension}
6678
on:contextmenu
6779
>
68-
<img alt="" src={getIcon(icons, 16)} />{shortName ?? name}
80+
<img alt="" src={getIcon(icons, 16)} />{realName}
6981
</button>
7082
{#if optionsUrl && enabled}
7183
<a href={optionsUrl} title={getI18N('gotoOpt')} on:click={openInTab}>

0 commit comments

Comments
 (0)