Skip to content

Commit 812afdb

Browse files
committed
fix: replace clipboardRead with textarea
1 parent 1e09ba9 commit 812afdb

File tree

5 files changed

+60
-29
lines changed

5 files changed

+60
-29
lines changed

import-urls/.import.js.swp

16 KB
Binary file not shown.

import-urls/README.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,30 @@
1-
[demo-2025-08-16_21.41.14.webm](https://github.com/user-attachments/assets/c88cd2d6-7711-435b-bbf1-f8186045c9cc)
1+
# NAME
2+
3+
**import-urls** - import urls from the clipboard or any text file as bookmarks or open them as tabs
4+
5+
# SYNOPSIS
6+
7+
click the toolbar button to open the importer tab view, then provide the text from which to extract the URLs
8+
9+
# USER INPUTS
10+
11+
- clipboard or file with urls
12+
- (optional) regular expression for URL extraction
13+
- (optional) bookmark folder
14+
- (optional) loading states for tabs
15+
16+
# OPTIONS
17+
18+
none
19+
20+
# REQUIRED PERMISSIONS
21+
22+
- **storage**: used to store regular expression for URL extraction
23+
24+
# OPTIONAL PERMISSIONS
25+
26+
- **bookmarks**: used when importing URLs as bookmarks
27+
28+
# DEMO VIDEO
29+
30+
https://github.com/user-attachments/assets/c88cd2d6-7711-435b-bbf1-f8186045c9cc

import-urls/import.html

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
background-color: lightgray;
88
min-height: 400px;
99
}
10-
#urlspreview {
10+
#urlspreview,
11+
#rawtext {
1112
min-height: 25em;
1213
white-space: pre;
1314
overflow-wrap: normal;
@@ -21,45 +22,50 @@
2122
</head>
2223
<body>
2324
<fieldset>
24-
<legend>Get URLs from ...</legend>
25+
<legend>1. Provide text to extract URLs from</legend>
2526
<div>
26-
<button id="impcbbtn">clipboard</button>
27-
or
28-
<span>
29-
text file
30-
<input id="impbtn" type="file" value="" />
31-
</span>
32-
<p>
33-
<span
34-
><abbr title="Regular Expression used to extract the URLs"
35-
>Extraction RegEx: </abbr
36-
><input id="extractregex" type="text"
37-
/></span>
38-
</p>
27+
<textarea id="rawtext"></textarea>
28+
load from file
29+
<input id="impbtn" type="file" value="" />
30+
<p />
31+
32+
<span
33+
><abbr title="Regular Expression used to extract the URLs"
34+
>Extraction RegEx: </abbr
35+
><input id="extractregex" type="text"
36+
/></span>
37+
38+
<p />
39+
40+
<button id="impcbbtn">2.Extract URLs</button>
3941
</div>
4042
</fieldset>
41-
URL Preview
43+
3. Preview URLs
4244
<textarea id="urlspreview"></textarea>
4345
<fieldset>
4446
<div id="status"></div>
4547
</fieldset>
4648
<fieldset>
47-
<button id="urlsopen">Open in tabs</button>
49+
<button id="urlsopen">4.Open in tabs</button>
4850
load tabs?
4951
<input type="checkbox" id="openLoad" />
5052
with seconds delay? <input type="number" id="openDelay" min="0" value="0" />
5153
</fieldset>
5254

5355
<fieldset>
56+
Or
5457
<select id="folders" disabled>
5558
<option value="">Create bookmarks in folder</option>
5659
</select>
5760

58-
<acronym id="reqBookmarkPermission" title="Request Permission">(?)</acronym>
61+
<acronym id="reqBookmarkPermission" title="Request Permission"
62+
>(click here to enable)</acronym
63+
>
5964
</fieldset>
6065

6166
<fieldset>
6267
<div id="status2"></div>
6368
</fieldset>
69+
6470
<script src="import.js"></script>
6571
</body>

import-urls/import.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const extREinput = document.getElementById("extractregex");
1616

1717
reqBMPer.addEventListener("click", async () => {
1818
if (!(await browser.permissions.request(requiredPermissionB))) {
19-
result.innerText = "Bookmark Permission not granted";
19+
result2.innerText = "Bookmark Permission not granted";
2020
return;
2121
}
2222
location.reload();
@@ -140,7 +140,8 @@ async function onLoad() {
140140
reader.onload = async function (/*e*/) {
141141
try {
142142
const data = reader.result;
143-
importData(data);
143+
//importData(data);
144+
document.getElementById("rawtext").value = data;
144145
} catch (e) {
145146
console.error(e);
146147
result.innerText = "Import failed!" + e;
@@ -152,12 +153,7 @@ async function onLoad() {
152153
let impcbbtn = document.getElementById("impcbbtn");
153154

154155
impcbbtn.addEventListener("click", async () => {
155-
if (!(await browser.permissions.request(requiredPermissionA))) {
156-
result.innerText = "Clipboard Read Permission not available";
157-
return;
158-
}
159-
const str = await navigator.clipboard.readText();
160-
importData(str);
156+
importData(document.getElementById("rawtext").value);
161157
});
162158
}
163159

import-urls/manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
"browser_action": {
88
"default_area": "navbar"
99
},
10-
"description": "Import URLs from clipboard or a text file as tabs or bookmarks",
10+
"description": "Extract URLs from text and import them as tabs or bookmarks",
1111
"icons": {
1212
"256": "icon.png"
1313
},
1414
"manifest_version": 2,
1515
"name": "Import URLs",
1616
"permissions": ["storage"],
17-
"optional_permissions": ["bookmarks", "clipboardRead"],
17+
"optional_permissions": ["bookmarks"],
1818
"version": "1.0.16"
1919
}

0 commit comments

Comments
 (0)