Skip to content

Commit

Permalink
fix(#7): inconsistent line ending per mode
Browse files Browse the repository at this point in the history
chore: remove some debug statements
  • Loading branch information
igorlogius committed Jul 27, 2023
1 parent 6ddd374 commit 1b911ba
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 26 deletions.
48 changes: 23 additions & 25 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,23 @@ function notify(title, message = "", iconUrl = "icon.png") {
}

async function copyTabsAsText(tabs) {
const text =
tabs
.map((t) => {
if (noURLParams) {
try {
let tmp = new URL(t.url);
console.debug(tmp);
if (tmp.origin !== "null") {
// origin seems to be "null" when not available which is a strange value, might be worth raising a bug on bugzilla for
tmp = tmp.origin + tmp.pathname;
return tmp;
}
} catch (e) {
console.error(e);
const text = tabs
.map((t) => {
if (noURLParams) {
try {
let tmp = new URL(t.url);
if (tmp.origin !== "null") {
// origin seems to be "null" when not available which is a strange value, might be worth raising a bug on bugzilla for
tmp = tmp.origin + tmp.pathname;
return tmp;
}
} catch (e) {
console.error(e);
}
return t.url;
})
.join("\r\n") +
"\r\n" +
"\r\n";
}
return t.url;
})
.join("\n");
try {
await navigator.clipboard.writeText(text);
return true;
Expand All @@ -61,12 +57,13 @@ async function copyTabsAsHtml(tabs) {
//
/// old
try {
let div = document.createElement("div");
let div = document.createElement("span"); // needs to be a <span> to prevent the final linebreak
div.style.position = "absolute";
div.style.bottom = "-9999999"; // move it offscreen
document.body.append(div);
for (const t of tabs) {
let br = document.createElement("br");
const tabs_len = tabs.length;
for (let i = 0; i < tabs.length; i++) {
let t = tabs[i];
let a = document.createElement("a");

if (t.url.startsWith("http") || t.url.startsWith("file")) {
Expand All @@ -80,10 +77,12 @@ async function copyTabsAsHtml(tabs) {
}
a.textContent = t.title;
div.append(a);
div.append(br);
if (i !== tabs_len - 1) {
let br = document.createElement("br");
div.append(br);
}
}

//console.debug("typeof navigator.clipboard.write ", typeof navigator.clipboard.write);
if (
typeof navigator.clipboard.write === "undefined" ||
typeof ClipboardItem === "undefined"
Expand Down Expand Up @@ -118,7 +117,6 @@ async function onCommand(cmd) {
if (!ready) {
return;
}
console.debug(cmd, showNotifications);
let qryObj = { hidden: false, currentWindow: true },
tabs,
ret = false;
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,5 @@
"menus",
"tabs"
],
"version": "1.13.38"
"version": "1.13.39"
}

0 comments on commit 1b911ba

Please sign in to comment.