Skip to content
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

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open

Conversation

kurahaupo
Copy link

@kurahaupo kurahaupo commented Aug 29, 2021

This PR is a repeat of PR #1688 by @sherry13131, but rebased on top of today's master.

In addition I have:

  • included some small tweaks to the style tags to bring it into line with other changes made to the same block.
  • cleaned up trailing whitespace on introduced code.
  • fixed a latent bug in the verification code when adding a new URL.

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.

@kurahaupo kurahaupo changed the title Issue 1670 Fix for Issue #1670 (rebased and cleaned up PR #1688) Aug 29, 2021
@kurahaupo kurahaupo changed the title Fix for Issue #1670 (rebased and cleaned up PR #1688) Fix for Issue #1670 - manually add URLs to a container (rebased and cleaned up PR #1688) Aug 29, 2021
@kurahaupo kurahaupo changed the title Fix for Issue #1670 - manually add URLs to a container (rebased and cleaned up PR #1688) Fix for Issue #1670 - manually add URLs to a container (refreshed PR #1688, rebased and cleaned up) Aug 29, 2021
@kurahaupo kurahaupo force-pushed the issue-1670 branch 6 times, most recently from abb7f12 to 7570c0e Compare August 30, 2021 08:07
@robsonsobral
Copy link

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);
Copy link

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,

Copy link
Author

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.

Copy link
Author

@kurahaupo kurahaupo Nov 25, 2021

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.

@ryanseddon
Copy link

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.

@phy1729
Copy link

phy1729 commented Nov 22, 2021

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.

@ryanseddon
Copy link

This is extremely helpful, thanks for sharing

@dvd0101
Copy link

dvd0101 commented Jan 3, 2022

@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:

  1. open about:devtools-toolbox?id=%40testpilot-containers&type=extension
  2. paste and run the function in the console panel
  3. still in the console panel call the function with the name of the container and the url to add, for example: addUrl("search", "https://domain.to.add")

@kurahaupo

This comment has been minimized.

@dvd0101
Copy link

dvd0101 commented Jan 4, 2022

@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 about:devtools-toolbox?id=%40testpilot-containers&type=extension url and pasted the code in the console of that page (not in the inspector console)?

@kurahaupo

This comment has been minimized.

@wolfferine
Copy link

wolfferine commented Jan 13, 2022

Please implement this feature soon - we're dying for it :-)
btw the title "Always Open This Site in..." is not correct (imho)
cause most ppl will assume it will always open a link/url
in a specific container, which is not the case!

Because:
https://outlook.live.com/owa/?username=me@ive.com
is different compared to
https://outlook.live.com/owa/?username=you@ive.com

@dannycolin dannycolin changed the title Fix for Issue #1670 - manually add URLs to a container (refreshed PR #1688, rebased and cleaned up) Manually add URLs to a container Dec 27, 2022
@swiffer
Copy link

swiffer commented Jan 16, 2023

LGTM

@TriMoon
Copy link

TriMoon commented Nov 13, 2023

@mozilla @ctbmozilla-admin @dannycolin PLEASE slap anyone needed to get this merged already, what's holding this off for so many years?

@kurahaupo
Copy link
Author

kurahaupo commented Nov 15, 2023

Rebased to current main again. (It was a clean rebase; there were no conflicting changes.)

Nomes77 added a commit to Nomes77/multi-account-containers that referenced this pull request Nov 16, 2023
Nomes77 added a commit to Nomes77/multi-account-containers that referenced this pull request Nov 16, 2023
Nomes77 added a commit to Nomes77/multi-account-containers that referenced this pull request Nov 16, 2023
Comment on lines +1949 to +1957
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"
/>`;
Copy link
Collaborator

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.

Copy link

@TriMoon TriMoon Nov 17, 2023

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 😉

@dannycolin
Copy link
Collaborator

PLEASE slap anyone needed to get this merged already, what's holding this off for so many years?

@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.

@TriMoon
Copy link

TriMoon commented Nov 17, 2023

@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...

@Bazoogle
Copy link

Bazoogle commented Jan 4, 2024

I can't promise anything but my University semester ends in ~1 month. Hopefully, I'll have time to look at it more closely.

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

@patienttruth patienttruth mentioned this pull request Jan 9, 2024
2 tasks
@Snake883
Copy link

Website redirects are causing me a lot of problems (live.com, outlook.com, microsoft.com, etc).
Being able to manually add websites/URL's to the container site list would presumably solve the problem of redirects going in and out of containers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet