Skip to content

Commit ece25bc

Browse files
committed
Update dependencies
1 parent 680d8cb commit ece25bc

11 files changed

+2653
-2278
lines changed

.eslintignore

-1
This file was deleted.

content_script.js

+43-44
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,23 @@
2424

2525
const createTextFragment = () => {
2626
const selection = window.getSelection();
27-
// eslint-disable-next-line no-undef
27+
2828
const result = exports.generateFragment(selection);
2929
let url = `${location.origin}${location.pathname}${location.search}${
3030
location.hash ? location.hash : '#'
3131
}`;
3232
if (result.status === 0) {
3333
const fragment = result.fragment;
34-
const prefix = fragment.prefix ?
35-
`${encodeURIComponent(fragment.prefix)}-,` :
36-
'';
37-
const suffix = fragment.suffix ?
38-
`,-${encodeURIComponent(fragment.suffix)}` :
39-
'';
34+
const prefix = fragment.prefix
35+
? `${encodeURIComponent(fragment.prefix)}-,`
36+
: '';
37+
const suffix = fragment.suffix
38+
? `,-${encodeURIComponent(fragment.suffix)}`
39+
: '';
4040
const textStart = encodeURIComponent(fragment.textStart);
41-
const textEnd = fragment.textEnd ?
42-
`,${encodeURIComponent(fragment.textEnd)}` :
43-
'';
41+
const textEnd = fragment.textEnd
42+
? `,${encodeURIComponent(fragment.textEnd)}`
43+
: '';
4444
url = `${url}:~:text=${prefix}${textStart}${textEnd}${suffix}`;
4545
copyToClipboard(url, selection);
4646
reportSuccess();
@@ -72,57 +72,57 @@
7272
const reportFailure = (status) => {
7373
const statusCodes = {
7474
1: 'INVALID_SELECTION: The selection provided could not be used.',
75-
// eslint-disable-next-line max-len
75+
7676
2: 'AMBIGUOUS: No unique fragment could be identified for this selection.',
7777
3: 'TIMEOUT: Computation could not complete in time.',
7878
4: 'EXECUTION_FAILED: Unknown error.',
7979
};
8080

8181
window.queueMicrotask(() => {
8282
alert(
83-
`🛑 ${browser.i18n.getMessage(
84-
'extension_name',
85-
)}:\n${browser.i18n.getMessage('link_failure')}\n\n(${
86-
statusCodes[status]
87-
})`,
83+
`🛑 ${browser.i18n.getMessage(
84+
'extension_name'
85+
)}:\n${browser.i18n.getMessage('link_failure')}\n\n(${
86+
statusCodes[status]
87+
})`
8888
);
8989
});
9090
return true;
9191
};
9292

9393
const copyToClipboard = (url, selection) => {
9494
browser.storage.sync.get(
95-
{
96-
linkStyle: 'rich',
97-
linkText: browser.i18n.getMessage('link_text_option_1'),
98-
},
99-
async (items) => {
100-
const linkStyle = items.linkStyle;
101-
// Send message to offscreen document
102-
const selectedText = selection.toString();
103-
const linkText = items.linkText;
104-
let html = '';
105-
if (selection.rangeCount) {
106-
const container = document.createElement('div');
107-
for (let i = 0, len = selection.rangeCount; i < len; ++i) {
95+
{
96+
linkStyle: 'rich',
97+
linkText: browser.i18n.getMessage('link_text_option_1'),
98+
},
99+
async (items) => {
100+
const linkStyle = items.linkStyle;
101+
// Send message to offscreen document
102+
const selectedText = selection.toString();
103+
const linkText = items.linkText;
104+
let html = '';
105+
if (selection.rangeCount) {
106+
const container = document.createElement('div');
107+
for (let i = 0, len = selection.rangeCount; i < len; ++i) {
108108
// prettier-ignore
109-
container.appendChild(
109+
container.appendChild(
110110
selection.getRangeAt(i).cloneContents());
111+
}
112+
html = container.innerHTML;
113+
}
114+
browser.runtime.sendMessage(
115+
{
116+
target: 'offscreen',
117+
data: { linkStyle, url, selectedText, html, linkText },
118+
},
119+
(response) => {
120+
if (response) {
121+
log('🎉', url);
111122
}
112-
html = container.innerHTML;
113123
}
114-
browser.runtime.sendMessage(
115-
{
116-
target: 'offscreen',
117-
data: {linkStyle, url, selectedText, html, linkText},
118-
},
119-
(response) => {
120-
if (response) {
121-
log('🎉', url);
122-
}
123-
},
124-
);
125-
},
124+
);
125+
}
126126
);
127127
};
128128

@@ -136,5 +136,4 @@
136136
return sendResponse('pong');
137137
}
138138
});
139-
// eslint-disable-next-line no-undef
140139
})(chrome || browser);

eslint.config.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export default [
2+
{
3+
ignores: ['fragment-generation-utils.js'],
4+
},
5+
];

0 commit comments

Comments
 (0)