Skip to content

Commit efa819d

Browse files
committed
feat: add "Open in New Tab" functionality and update manifest permissions
1 parent 90d3f36 commit efa819d

File tree

4 files changed

+397
-248
lines changed

4 files changed

+397
-248
lines changed

manifest.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,7 @@
3131
"type": "module"
3232
},
3333

34-
"web_accessible_resources": [
35-
{
36-
"resources": ["welcome.html"],
37-
"matches": ["<all_urls>"]
38-
}
39-
],
34+
4035

4136
"content_scripts": [
4237
{

popup-page-scripts/popup-page-script.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ const copyProfileInput = document.getElementById('copyProfileInput');
3838
const cancelAddProfileButton = document.getElementById('cancelAddProfile');
3939
const cancelCopyProfileButton = document.getElementById('cancelCopyProfile');
4040

41+
// Open in Tab Button
42+
const openInTabButton = document.getElementById('open-in-tab-button');
43+
4144
// -------------------------
4245
// Debounced Save Function
4346
// -------------------------
@@ -164,6 +167,19 @@ function updateInterface() {
164167
// -------------------------
165168

166169
document.addEventListener('DOMContentLoaded', () => {
170+
// Check if the page is opened in a tab and apply appropriate styling
171+
const urlParams = new URLSearchParams(window.location.search);
172+
const isTab = urlParams.get('isTab') === 'true';
173+
174+
if (isTab) {
175+
// Hide the "Open in New Tab" button when already in a tab
176+
if (openInTabButton) {
177+
openInTabButton.style.display = 'none';
178+
}
179+
// Add tab-mode class to body for centering
180+
document.body.classList.add('tab-mode');
181+
}
182+
167183
loadProfiles();
168184

169185
// Profile management
@@ -301,6 +317,18 @@ document.addEventListener('DOMContentLoaded', () => {
301317
}
302318
});
303319

320+
// Open in New Tab Button Click
321+
if (openInTabButton) {
322+
openInTabButton.addEventListener('click', () => {
323+
// Open popup.html in a new tab with isTab parameter
324+
chrome.tabs.create({
325+
url: chrome.runtime.getURL('popup.html?isTab=true')
326+
});
327+
// Close the popup window
328+
window.close();
329+
});
330+
}
331+
304332
// Initialize event listeners for dynamic elements
305333
textareaSaverAndResizerFunc();
306334
attachEmojiInputListeners();

popup-page-styles/popup-base.css

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ body {
4747
transition: background-color var(--transition-duration) ease;
4848
}
4949

50-
/* Hide version container when the user is adding or copying a profile */
50+
/* Hide version container when the user is adding or copying a profile, as this space is used for that functionality at that sequence */
5151
body:has(#addProfileContainer:not([style*="display: none"])) #versionContainer,
5252
body:has(#copyProfileContainer:not([style*="display: none"])) #versionContainer {
5353
opacity: 0;
@@ -58,21 +58,21 @@ body:has(#copyProfileContainer:not([style*="display: none"])) #versionContainer
5858
#versionContainer {
5959
opacity: 1;
6060
pointer-events: auto;
61+
text-align: center;
6162
transition: opacity 0.5s ease;
6263
}
6364

6465
/* Centered version text styling */
6566
#version {
66-
text-align: center;
6767
color: #666666;
6868
width: 100%;
6969
}
7070

7171
/* Explanation text styling */
7272
#topExplanationText {
73-
text-align: center;
7473
color: #666666;
7574
width: 100%;
75+
margin-bottom: 12px; /* Reduces space below the paragraph, above the button */
7676
}
7777

7878
/* Notification text styling */
@@ -139,3 +139,4 @@ h2:hover {
139139
color: #6a4abd;
140140
transition: color var(--transition-duration-release) ease;
141141
}
142+

0 commit comments

Comments
 (0)