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

Allow setting Firefox profile path so jupynium can remember passwd or token #17

Closed
fecet opened this issue Jan 17, 2023 · 9 comments
Closed
Labels
enhancement New feature or request

Comments

@fecet
Copy link
Contributor

fecet commented Jan 17, 2023

I have play jupynium for a while and it works like a charm, however I found it's annoying to enter token(passwd) everytime. A simple but less elegant way is to make selenium refer to default profile:

def webdriver_firefox():
    profile = webdriver.FirefoxProfile("/home/username/.mozilla/firefox/7kl5jw0d.default-release/")
    profile.set_preference("browser.link.open_newwindow", 3)
    profile.set_preference("browser.link.open_newwindow.restriction", 0)
    # profile.setAlwaysLoadNoFocusLib(True);
    return webdriver.Firefox(profile, service_log_path=os.path.devnull)

the directory can be found by https://support.mozilla.org/en-US/kb/profiles-where-firefox-stores-user-data#w_how-do-i-find-my-profile. ("~" refer to home seems not work for me btw).

This is good enough for me, but I'm sure you have better ideas :)

@fecet fecet added the enhancement New feature or request label Jan 17, 2023
@kiyoon
Copy link
Owner

kiyoon commented Jan 17, 2023

Hi, I can add an option to set the profile directory, with expanding ~ as well.
Another good solution can be #12. When this gets implemented it will be easier to open the notebook whenever you need.

Thanks for the feedback!

@kiyoon
Copy link
Owner

kiyoon commented Jan 17, 2023

Do you also have the file profile.ini? I think it is more elegant to provide a path to that file so you don't need to configure the directory every machine differently

@fecet
Copy link
Contributor Author

fecet commented Jan 18, 2023

Just knew profile.ini is a thing, so it's definitely a better way.

I usually connect to a remote hosted notebook, so I guess #12 does not help me a lot?

@kiyoon
Copy link
Owner

kiyoon commented Jan 18, 2023

I see, actually for me I do both a lot. I'll make the profile option available soon

@kiyoon
Copy link
Owner

kiyoon commented Jan 19, 2023

This has been implemented. Please try and let me know! Thanks for such a cool suggestion!

@kiyoon kiyoon closed this as completed Jan 19, 2023
@fecet
Copy link
Contributor Author

fecet commented Jan 19, 2023

The default profile for me seems not as expected, it's look like

[Install4F96D1932A9F858E]
Default=nlk07dgt.default-release
Locked=1

[Profile1]
Name=default
IsRelative=1
Path=smhzf393.default
Default=1

[Profile0]
Name=default-release
IsRelative=1
Path=nlk07dgt.default-release

[General]
StartWithLastProfile=1
Version=2

And I have to manually set profile0 default as 1 and delete that for profile 1. That's not a big deal but worth noting.

However, that function works fine for me out of neovim:

from jupynium.cmds.jupynium import webdriver_firefox

driver=webdriver_firefox()

But in :JupyniumStartAndAttachToServer it still open a firefox which profile located in a random tmp dir.

Edit: I check about:profiles for start jupynium in and out neovim, they are identical, but if open under neovim, the language setting and add-ons are disapper and looks like a brand new firefox.

@kiyoon
Copy link
Owner

kiyoon commented Jan 19, 2023

I put the option in the nvim setup as well. Can you pass firefox_profile_name = "default-release"? I don't know why some settings have weird defaults..

Or maybe the firefox_profiles_ini_path is wrong. If it can't be read correctly it will open without a profile directory like before.

require("jupynium").setup({
  -- Used to remember the last session (password etc.).
  -- You may need to change the path.
  firefox_profiles_ini_path = vim.fn.isdirectory(vim.fn.expand "~/snap/firefox/common/.mozilla/firefox")
      and "~/snap/firefox/common/.mozilla/firefox/profiles.ini"
    or "~/.mozilla/firefox/profiles.ini",
  firefox_profile_name = "default-release", -- nil means the default profile
})

@fecet
Copy link
Contributor Author

fecet commented Jan 19, 2023

Weird thing is Lua style conditional operator break something, I have to explicitly set

firefox_profiles_ini_path = "~/.mozilla/firefox/profiles.ini",

And then the behavior of ":JupyniumStartAndAttachToServer " and "jupynium" in cli agree. (Otherwise the previous one will open firefox without add-ons, settings, account, etc, but about:profiles do say it open with the correct profile)

Not sure if I'm the only one with this problem, I think you can ignore it until someone else report the same issue if you cannot reproduce.

@kiyoon
Copy link
Owner

kiyoon commented Jan 19, 2023

Maybe you also have the snap directory? Or is my code just wrong..

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

No branches or pull requests

2 participants