Skip to content
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
1 change: 1 addition & 0 deletions eslint/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ module.exports = {
'BACKGROUND_TEST': 'readonly',
'RELOAD_EXTENSION': 'readonly',
'OPEN_URLS_IN_TABS': 'readonly',
'COPY_TO_CLIPBOARD': 'readonly',
'OPEN_LINKS': 'readonly',
'COPY_LINKS': 'readonly',
'isChrome': 'readonly',
Expand Down
12 changes: 12 additions & 0 deletions src/background-scripts/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,21 @@ function onMessage(msg, sender, respond) {
case OPEN_URLS_IN_TABS:
OpenUrlsInTabs(msg.tUrls);
break;
case COPY_TO_CLIPBOARD:
CopyToClipboard(msg.tUrls);
break;
}
}

/**
* @param {string[]} urls
* @return {Promise<void>}
*/
async function CopyToClipboard(urls) {
let platformInfo = await browser.runtime.getPlatformInfo();
navigator.clipboard.writeText(urls.join(platformInfo.os === chrome.runtime.PlatformOs.WIN ? '\r\n' : '\n'));
}

/**
* @param {string[]} urls
* @return {Promise<void>}
Expand Down
5 changes: 4 additions & 1 deletion src/content-scripts/ActionMgr.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ class ActionMgr {
if(Prefs.DevMode && Prefs.Dev_Skip_AllActions)
return console.log('Skipped Copying Links: %o', links);

navigator.clipboard.writeText(links.join('\r\n'));
browser.runtime.sendMessage({
Action: COPY_TO_CLIPBOARD,
tUrls: links,
});
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ const OPEN_LINKS = 1, // Open links
// Actions
const BACKGROUND_TEST = 'BackgroundTest',
RELOAD_EXTENSION = 'ReloadExtension',
OPEN_URLS_IN_TABS = 'OpenUrlsInTabs';
OPEN_URLS_IN_TABS = 'OpenUrlsInTabs',
COPY_TO_CLIPBOARD = 'CopyToClipboard';

const TABS_OPEN_END = 'OpenTabsAtEnd',
TABS_OPEN_RIGHT = 'OpenTabsToRight',
Expand Down