-
Notifications
You must be signed in to change notification settings - Fork 350
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Manually add URLs to a container #2114
Conversation
abb7f12
to
7570c0e
Compare
Somebody please review and merge this! PLEEEEEEEEEEEEEEEEEEASE! |
const userContextId = formValues.get("container-id"); | ||
const currentTab = await Logic.currentTab(); | ||
const tabId = currentTab.id; | ||
const baseURL = this.normalizeUrl(url); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure normalization isn't necessary. Assuming the below call to Logic.setOrRemoveAssignment
should be Utils.setOrRemoveAssignment
,
Utils.setOrRemoveAssignment
send a message whichmulti-account-containers/src/js/utils.js
Lines 93 to 99 in 50f5ebf
return browser.runtime.sendMessage({ method: "setOrRemoveAssignment", tabId, url, userContextId, value }); - the anonymous function in
messageHandler.init
handles by callingresponse = assignManager._setOrRemoveAssignment(m.tabId, m.url, m.userContextId, m.value); assignManager._setOrRemoveAssignment
which callsmulti-account-containers/src/js/background/assignManager.js
Lines 560 to 563 in 50f5ebf
await this.storageArea.set(pageUrl, { userContextId, neverAsk: false }, exemptedTabIds); storageArea.set
which filters the URL throughconst siteStoreKey = this.getSiteStoreKey(pageUrlorUrlKey); storageArea.getSiteStoreKey
which extracts the hostname and possibly the port from the URLmulti-account-containers/src/js/background/assignManager.js
Lines 14 to 20 in 50f5ebf
const url = new window.URL(pageUrlorUrlKey); const storagePrefix = "siteContainerMap@@_"; if (url.port === "80" || url.port === "443") { return `${storagePrefix}${url.hostname}`; } else { return `${storagePrefix}${url.hostname}${url.port}`; }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fairly new to this, so any help you can give - perhaps a PR into my patch - would be very much appreciated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the point of normalizeUrl
to trim the path off? Given that it's random user input, this seems like a fairly sensible idea.
It looks like you're right about the Utils.setOrRemoveAssignment
since it's only defined in src/js/utils.js, so I've committed that change too.
Can we get this moving again? Can I help? I have a lot of containers setup and I can't log into or use a lot of websites that do quick redirects at certain stages. |
While it'd be preferable to have a proper solution like this PR, in the mean time I've resorted to generating javascript to paste into the extension's console. I've documented the steps at https://github.com/phy1729/container-config in case that's useful for you too. |
This is extremely helpful, thanks for sharing |
602ae40
to
4c20fcb
Compare
@phy1729 thank you for your hack! I use your code in this function (hope it can help others): // open: about:devtools-toolbox?id=%40testpilot-containers&type=extension
//
// adapted from: https://github.com/phy1729/container-config
async function addUrl(container, url) {
const identities = await browser.contextualIdentities.query({ name: container });
if (identities.length > 1) throw new Error("too many container with the same name");
if (identities.length == 0) throw new Error("container not found");
const cookieStoreId = identities[0].cookieStoreId;
const userContextId = backgroundLogic.getUserContextIdFromCookieStoreId(cookieStoreId);
console.log("user context: ", userContextId);
const assignManager = window.assignManager;
await assignManager._setOrRemoveAssignment(false, url, userContextId, false);
} To use it:
|
This comment has been minimized.
This comment has been minimized.
@kurahaupo Tested right now and the "browser" symbol is visible (FF 96b10 and the mac extension up-to-date). Are you sure you have opened the |
This comment has been minimized.
This comment has been minimized.
Please implement this feature soon - we're dying for it :-) Because: |
LGTM |
@mozilla @ctbmozilla-admin @dannycolin PLEASE slap anyone needed to get this merged already, what's holding this off for so many years? |
d77997e
to
70cbaf8
Compare
Rebased to current |
trElement.innerHTML = Utils.escaped` | ||
<div class="favicon"></div> | ||
<div title="${site.hostname}" class="truncate-text hostname"> | ||
${site.hostname} | ||
</div> | ||
<img | ||
class="pop-button-image delete-assignment" | ||
src="/img/container-delete.svg" | ||
/>`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know we used Utilss.escaped
somewhere else in the code but we actually wanted to remove it in favor of createElement
, appendChild
, textContent
and whatever else that is considered safe. Plus, it always trigger the linter and AMO safety check because of innerHTML
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh man THAT looks very prehistoric indeed... 🤦♀️
But lets concetrate on getting the functionality merged in first, after that another PR can fix the innerHTML
mess, unless this PR is the one who introduces them 😉
*edit:
I just saw it is indeed this PR that introduces them...
@kurahaupo please re-code the innerHTML
mess 😉
@TriMoon It won't get things to move faster. I'm pretty much the only person who contributed to anything containers lately. However, I'm not a paid staff and lack the free time to do a good review at the moment. I can't promise anything but my University semester ends in ~1 month. Hopefully, I'll have time to look at it more closely. |
@dannycolin i understand but the rest of us are unable to merge even if we would create PR's, so it's up to the ones with permissions to do it... |
Hope you had a good holiday! I know you didn't promise anything, but I'm curious if this is still on your to-do list. Totally understandable if you have more pressing things to address, but I wanted to let you guys know there's still those of us who would love this feature! Thank you for your contributions, regardless of if you're able to do this or not. Your voluntary contributions have helped many |
Website redirects are causing me a lot of problems (live.com, outlook.com, microsoft.com, etc). |
Superseded by #2710. It's moving slowly but it's coming y'all. |
This PR is a repeat of PR #1688 by @sherry13131, but rebased on top of today's master.
In addition I have:
The original code allowed any text containing any URL to be added, which I'm pretty sure would result in entries that would never be matched, so I added my own commit that trims any provided URL so that they are just http(s)://dom.ain (with any username, password, port, path, query string and/or anchor removed).
Because I've rebased the code, a number of merge commits in the original PR have vanished, but they were purely between internal development branches in the same repo, not part of the main PR.