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

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.

Related

Specifying a target tab (or window) in a URL

I'm still struggling with the issue I described here: I need to send the user a document and the only tool available to me is requesting a URL to be opened in the default browser.
That works fine but if I link to the document directly, the browser (IE, FF, Chrome, Opera and Safari tested) creates a new, empty tab behind.
I would like to find a way to avoid that.
An additional issue is that users can use a very similar functionality to bypass the login screen and go directly to a specific page of the web app. Unfortunately, since all I have to work with is a URL, every time they invoke that function they end up opening a new tab.
So, I thought that one to solve both issue would be to be able to specify the target of the URL (as if the used clicked on a <a target="mywebapp"> link). Is that possible either through the URL itself or through the web page targeted?

Creating multiple sessions with each new tab with chrome extension

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.

Wiping browser history with javascript (or preventing URL from being recorded)

I have a client (domestic violence center) who wants to know if we can prevent their site from showing up in browser history, or wipe the users visit from their browser history when they exit the site.
I know once someone is on the site we can build it in ways that prevent new pages from loading like a normal page using location.replace for navigation, but that initial page visit when someone typed in http://example.org will still be in the history.
Is it possible on page load to prevent the page from being recorded in the history, or erase the record if it exists?
I have a bad feeling it can't, but if anyone will know it's all my smartypants friends on Stack Overflow.
Unfortunately this can't be done.
For your clients scenario, my best advice would be that users are educated on how to remove their visit from their browser history, and how to use anonymous browsing/private mode/incognito mode in future visits.
Quoting MDN:
There is no way to clear the session history or to disable the
back/forward navigation from unprivileged code. The closest available
solution is the location.replace() method, which replaces the current
item of the session history with the provided URL.
So I think what your client wishes for is just not possible.
Add script to recognise each browser, and provide browser specific steps to erase history/use incognito mode.
A properly configured proxy server may be of use in that context.

Read Chrome browsing history within extension

How can I check if a certain link is found in Chrome's browsing history(on the computer that accesses the link) using JavaScript or jQuery? I am interested (if any) in the functions that I have to use. Also how can I get the date and time of the accessed link?
Retrieving the users history from javascript launched from a web page is impossible due to obvious blatant security issues.
Retrieving the users history from javascript running in an extension is possible, but doing so requires elevated permissions that the user has to grant after being warned. In summary you are probably looking for the chrome.history.getVisits() function. You can find more information on how to access the history using chrome.history here and the resulting security warnings given to the user here.
Nonono! That cannot happen. Unless you make a plugin, but I still doubt it.
This might be off topic but you might be interested in google analytics.
this chrome extension allow you to use browser address bar to search keywords, which will automatically search against your browser history and give you suggestion
Chrome webstore - history as bookmark
This is just not possible with Chrome because of security. What you would have to do is use cookies and add to the cookie each page the user is on along with the time visited.
Problem with this it will only track a user on your site not others. Cookies are only suppose to hold small amounts of info not long tracks of what page your user has been on. Also a user can disable cookies...
Another way is maybe doing this serverside and tracking the users IP through your pages and keep a list of what pages your user is visiting.

Can I use javascript to add a bookmark that is not a http url?

I have this bookmarklet, i.e. it does not start with 'http:' but with 'javascript:'. No issue with that, it works correctly.
The problem occurs when I want to deploy this to users. I'd like to present them a link they'll just click to add to their favorites. Whatever methods I use (examples found on the web, or JQuery with jFav), I end up with a javascript error 'permission denied' when clicking the link, though it works perfectly when the link to bookmark is a classic 'http' one.
I believe that's some security in browsers, but is there a way to avoid this?
It is indeed a security measure. If a user could be tricked into bookmarking and running a javascript: URL, that's pretty much global cross-site-scripting.
About all you can do is present the user with a javascript: link, and ask them to bookmark it via right-click-bookmark or drag-to-bookmarks. You should also write the link out so it can be copy-and-pasted and manually bookmarked, because some browsers won't present right-click-bookmark for a JavaScript link, and others may not have a bookmarks bar visible.
You can ask your users to drag and drop the bookmarklet to the their bookmarks or toolbar.

Categories