Skip to content

Commit

Permalink
Make it work in private window and containers
Browse files Browse the repository at this point in the history
  • Loading branch information
kudlatyamroth committed Jan 6, 2019
1 parent 7f1ac50 commit aec307d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 11 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "Xdebug Session Cookie",
"version": "1.1",
"version": "1.2",

"description": "Adds cookie that enables XDEBUG SESSION for php xdebug.",
"homepage_url": "https://github.com/kudlatyamroth/xdebug-session-cookie",
Expand Down
38 changes: 28 additions & 10 deletions xdebug.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,25 @@ async function updateIcon() {

async function toggleCookie() {
let cookie = await getCookie();
let currentUrl = currentTab.url;

if (cookie) {
browser.cookies.remove({
url: currentTab.url.replace(/:{1}[0-9]{1}\d*/, ''),
name: cookieName
url: currentUrl.replace(/:{1}[0-9]{1}\d*/, ''),
name: cookieName,
storeId: currentTab.cookieStoreId
});
updateIcon();
return null;
}

let config = await browser.storage.sync.get('xdebug_session');

let valueToSet = await getValueToSet();
browser.cookies.set({
url: currentTab.url,
url: currentUrl.replace(/:{1}[0-9]{1}\d*/, ''),
name: cookieName,
value: config.xdebug_session || 'phpstorm',
path: "/"
value: valueToSet,
path: "/",
storeId: currentTab.cookieStoreId
});
updateIcon();
}
Expand All @@ -56,11 +58,27 @@ async function getIcons(cookie) {
}
}

async function getValueToSet() {
let config = await browser.storage.sync.get('xdebug_session');

return config.xdebug_session || 'phpstorm';
}

async function getCookie() {
return browser.cookies.get({
url: currentTab.url.replace(/:{1}[0-9]{1}\d*/, ''),
name: cookieName
let currentUrl = currentTab.url;
let valueToSet = await getValueToSet();

let cookie = await browser.cookies.get({
url: currentUrl.replace(/:{1}[0-9]{1}\d*/, ''),
name: cookieName,
storeId: currentTab.cookieStoreId
});

if (cookie && cookie.value == valueToSet) {
return cookie;
}

return null;
}

async function updateActiveTab() {
Expand Down

0 comments on commit aec307d

Please sign in to comment.