Creating multiple sessions with each new tab with chrome extension - javascript

I'm trying to create a new session with each new opened tab. So if I call "chrome.tabs.create" and hit the same url I would like it to create a new session. For example if I hit one page and they use cookies to store my cart when I call "chrome.tabs.create" for a second time it just retrieves my previous session and both tabs are essentially the same thing. Is there a way to do this?

No, not really, not with an extension.
You can open an incognito tab, but that gives you a second session, you can't open "another" incognito context until you close the first one.
A Chrome App can use webviews with different partitions to this effect, but cannot really interact with normal browsing.
Webview is not yet available for extensions and it's unclear when that will change.
If you need this really badly you can try manipulating cookies with chrome.cookies API.

I tested many exteension in Chrome and even the SessionBox seems promising I encouterned some bugs so that I cannot use it easily: I had to recreate my profile everytime regularly.
Afer that I found a chromium fork called ghostbrowser which have exactly the feature your need to.
This is a very good alternative as long you are ok with the 4 identities limitation of the Free version.

Related

Make site not appear in history (through code, not user)

I'm creating a website for people who need help (getting abused and stuff).
There is an 'escape' button on the site to switch to another site if someone wants to hide what they were looking for. But the visited page is still in the history of the browser.
Is there any way to make the site remove itself from browser history?
Or does the user need to activate 'incognito' ?
location.replace SHOULD have done this
The Location.replace() method replaces the current resource with the one at the provided URL. The difference from the assign() method is that after using replace() the current page will not be saved in session History, meaning the user won't be able to use the back button to navigate to it.
try
This test
<button type="button" onclick="location.replace('https://safe.site.com')">Leave</button>
which will replace CURRENT page - so your site needs to be a single page application (SPA) OR every click on the page needs to do location replace too
But yes, suggest incognito
It's not possible to clear user history without plugins.
For information refer to How to clear browsers (IE, Firefox, Opera, Chrome) history using JavaScript or Java except from browser itself?
There is no way of doing this. You have no control over browser history.
It's possible (under Firefox anyway) to delete history using history.deleteAll()
but that requires an extension to be added (documentation: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/history/deleteAll). Which probably doesn't help.

How to force external links to open in an existing web app?

I cannot find anything about it but I find it hard to believe no one has ever tried this.
I'm looking for a client-side solution that allows me to re-use an existing web application running in a browser tab/window when a link is 'clicked' externally.
For example, someone sends me en email with 10 links pointing to a web app (http://myapp.com/:id)
I just want a single instance of that web app to avoid opening a new tab when a link is clicked. My app is really heavy to load and already manages its own tabs re-using existing data.
I've currently implemented this using a Chrome extension that closes the tab if there is an existing one with the same domain, but I want a better cross-browser solution (at least Firefox)
Does anyone know how to achieve this using JS?
I was thinking of Shared workers, but I'm sure there is no way to focus a browser tab using JS...
Thanks!

chrome extension update and rewrite to another same extensions

hello i have chrome extension which adds background.html as new tab.
its like speed deal , when you are opening new tab it automatly opens.
i have 26k users but every day only half visits my extension. (opens new tab with my background html) because after my extension maybe users installed another junk extensions which adds website as new tab.
so i want to return back my users by update.
<html>
<head></head>
<body style="margin:0px;padding:0px;">
<iframe
style="width:100%;height:100%;margin:0px;padding:0px;border:none;"
src="/background.html"
name="ext-newtab-iframe"></iframe>
</body>
</html>
my extensions code looks like that how can i change if i want to return back my users. i want to rewrite it to another extensions
You can't programmatically retake the new tab page. The most recently downloaded new tab extension overrides the new tab page, and your scripts have no access to another extension's pages or scripts. Even if you could do it I would not suggest it.
why not?
By doing so you give your users that are using another new tab extension a reason to uninstall your extension. Maybe they don't want your extension anymore, or maybe they kept your extension to use it later. But if it overrides what they want, they won't be happy. Which means you will loose installs, and maybe get a few bad reviews which isn't ever good.
You shouldn't take control over what your users want or don't want. Users expect to be able to do whatever they want to do with your extension, and as a result they'll be happy.
I don't know how reliable your analytics are, but a lot of people don't use their computers every day. Others could be using their laptop for a day, and their chromebook the next. There aren't necessarily that many people that aren't actively using your extension.
Solution:
If you want you could open a page when your extension updates notifying your users of any changes, and reminding those that aren't using it that they have it.
READ:
http://www.swansonrussell.com/perspectives/articles/are-you-annoying-your-web-users , specifically the 3rd reason

accessing other tab from one window

How does the browser treat multiple tab? Are they completely separate entity where no interaction is possible? I understand the sandbox concept of the browser and other security concerns but is it possible for a webpage to interact with another tab in the browser?
Basically my question is: If a user loads one webpage in a new tab, is there some way to access information of other tab which is already opened or will be opened after?
I have one concept of an application which needs to know about the other tab already opened or opened after my conceptual webpage but I don't know if this is possible.
As far as I know, this isn't possible. The browser wouldn't allow you to manipulate the browser's lower functions in a regular environment. It would ignore it or show a security error come up.
I think there is no way to do that, except when both documents are written to communicate with each other (Like in vBulletin new windows). The only way to access tabs is writing Add-Ons for the browser.
There is no way to access other tabs on the client-side.
However, I can imagine a scenario in which this could be done server side. Have the user log in to your site on both tabs and use something like sockets to pass data back and forth from one tab to the other using the server as a middle-man.
If both pages are from the same domain, you can use cookies or, in HTML5, local storage.
If you own the other tabs, you can broadcast to other tabs, and other tabs can broadcast back to your tab, creating a practical communication channel among them.
This is called Inter-window messaging, and it uses LocalStorage.
To simply check if you are the active tab, use $(window).blur( ... ), or a similar technique using a library of your choice.

Can a session cookie be set in Javascript so only that browser instance sees it?

Is there a way to set a browser session cookie in Javascript, so that only that browser instance can see that cookie. For example, if I set a cookie via Javascript in one instance of Firefox, and then invoke a second instance of Firefox (Ctrl-N or launching firefox.exe again), I do not want that second instance to be able see this cookie.
How would I go about this? Thank you.
You can't. Different browser windows are just different windows to the same instance. Launching Firefox again just spots the running instance and opens a new window in it.
(There are some command line options which might open a new instance (in particular the one to load a different user profile), but that is entirely a client issue and any JS is by the by).

Categories