I'm developing a google chrome extension that will insert a button in facebook profile cover, using content script that documented in chrome API i can insert that button on the refresh the page or open the profile in other window - tab, the problem is open any profile link in the same window - tab will not add that button! I think facebook load the content via AJAX without refresh the page.
I used that code:
$("div#contentArea").on("DOMNodeInserted DOMSubtreeModified DOMNodeRemoved",function() {
// Do somthing
});
but it does not fire on navigate between profiles!
How to know if the user is open other profile? I'm thinking to check url for every 1 seconds but is that the final solution?
I know it's been long time for this question, but I see it will be better to share the solution, a new one!
It's not good to use any of these DOMNodeInserted DOMSubtreeModified DOMNodeRemoved, instead use this API from HTML5 MutationObserver.
There is more than that you can use within MutationObserver is this library mutation-summary.
Thanks for Firefox developers because they share this with me when I submitted this add-on to store.
Best if luck to all.
Related
I'm tiring to login with google on popup window, that of course I'm opening in my code with window.open(). The problem is that I couldn't listen load envent on the new window because, the popup belong to other domain (google) and the event is Blocked by JavaScript.
I need to know when the popup is opened and when de user is logged in (url changes, and navigate to my own callback page).
Please can someone help me!!!
Thanks very much.
There is no way to do that with a site that does not cooperate.
If you are trying to use Google as a login service for your site, you can look at OAUTH.
The way it works is, in short:
Call Google
Give them a web page to call if the login works.
I am working on a client site where the client has requested that there be a button (basic a link) that links to another page like google, in case an abusive significant other busts into the room while a woman is reading about how to get assistance. The tricky part is that I am trying to figure out to link to a page that will open int he same windows, but no let you go back to the site by clicking the browser's back button, or show up in "history". I have built a lot of website and never heard of this being possible without the use of a custom browser extension or something.
My question is ..
Is there a way to do this? Possible some JS magic? Just wondering
You're looking for location.replace().
<button onclick='location.replace("https://www.google.com");'>Click to close</button>
Instead of creating a new entry in browser history, it replaces the current one.
Note: Unfortunately, it's blocked by [SO]. But just try it in your app. It does work.
Second note: If you combine this with initially opening the to be hidden page in a new tab (target="_blank") => no history.
However, the best method and advice for such cases is browsing in incognito: Ctrl+Shift+N. Once closed, it's gone, with all history in the session. Pressing Ctrl+Shift+T in a new browser window won't bring the formerly opened tabs back.
IMHO, this technique should be clearly detailed in the "Precautions" section of your client's website, also advising on having another "normal" browsing session opened in a background browser window, with a few neutral tabs open on subjects that wouldn't raise any suspicions: cooking recipes, things for children, cosmetics, etc...
I am not sure about your question.
But on click you can open Iframe
<iframe src="www.google.com" style="border:none;"></iframe>
I want create a plugin that detects whether a user navigated to another page by clicking on a link or by typing in a new URL in the omnibar.
Is it possible in a Chrome extension to detect whether a webrequest was made from within a page or by a user from the omnibox?
For anyone trying to find out how to do this:
You can use the following function: http://developer.chrome.com/extensions/webNavigation.html#event-onCommitted
It gives back whether a request came from the address bar.
Most resources suggest using onclick handler with trackEvent() for tracking outgoing links. BUT this way does not work with all navigation methods! It won’t work if you click with middle button (except Chrome) or control-click (except Chrome and FF) to open new tab, if you right-click and select new tab or window from context menu or if you drag link to another tab. Is such cases onclick is simply not called. You can check it with very simple link:
GO
Putting JavaScript in href attribute breaks the link in all cases when new tab or window is opened.
Putting onclick in span that looks like a link, will not allow users to decide if they want to open in new tab or not.
Finally, going through a redirect page, which tracks outgoing event, causes problems with back navigation – when users try to go back, they get back to the redirect page and then JS again redirects to the destination page. They need to click back twice … quickly.
Is there a better way, which would be both accurate and user friendly?
Context menu can't be detected by using JS. So if you want to catch that you need to use the redirect method. To fix the back button problem, redirect using location.replace to remove the tracking page from the back-button history.
I don't know any details about Google Analytics. In general, to track users' external navigation:
<a ping> is made for this purpose. If ping is not available, fall back to changing the links to go through a redirect page. Use a 302 redirect to prevent it from showing up in history; if you can't, try javascript:window.location.replace().
Facebook Connect has a recent bug that is causing the permissions pop-up window to not close and refresh the parent window as it is designed to do. Instead, after approval by the user it attempts to load the page directly in the pop-up window which is an awful user experience and really hurting our registrations. You can see the bug by registering for our site using Facebook Connect: http://alltrails.com
The URL of the page after the user connects that Facebook Connect is incorrectly loading in the permissions pop-up window is of the form:
http://alltrails.com/?installed=1&session={"session_key":"2.Gu0duOqdElNjXRac5wnetw__.3600.1283799600-1486832834","uid":1486832834,"expires":1283799600,"secret":"tKFaEgBTF9RJeuQZfYUSCw__","base_domain":"alltrails.com","sig":"a8dd9f75418b530ae6c3d935e14274c4"}
I'm hoping that someone much better at JavaScript than myself could suggest a simple code snippet that we could add to our homepage that would only be invoked if the page URL includes '?installed=1' and would do the following to allow the same user experience as Facebook Connect was intended to provide:
Close the permissions pop-up window
Load the appropriate page http://alltrails.com/register/facebook in the original parent window
I've tried to do this a bunch of different ways but haven't had any luck with getting it to work correctly. Thanks in advance for your help!
It's a (unconfirmed) bug.
http://bugs.developers.facebook.net/show_bug.cgi?id=12260
Hopefully it gets more votes so it gets fixed - vote people!
In the meantime, i am (attempting) to employ the following 'creative workaround':
Add logic to my Default.aspx page to detect that URL they are redirecting to in the popup.
Redirect to my page, FacebookInboundAuthorization.aspx, preserving querystring.
On load of that page, register some JavaScript to close the popup and manually fire the "onlogin" event handler for my button.
EDIT - Another possible solution
So i do something like this for the "Disconnect from Facebook" button, which has a similar bug which has been in FBC from day 1. If the user is already logged in, and you click the "Disconnect from Facebook" button, the "onlogin" handler is not fired.
So what i ended up doing is replacing the Facebook Disconnect button with my own regular anchor tag, mimicing the Facebook CSS. This way i can have full control over the click event (fire the function i want).
So, this principle could (theoretically) be applied to this current bug.
That is, after you do FB.Init on client-side:
Check FB auth status using FB.Connect.ifUserConnected
If user is connected, hide the regular FB:Login button, and show your "fake" FB Login button. Copy across the "onlogin" function from your regular FB:Login button to your fake button as the onclick event.
Your Fake FB Login button would be a regular anchor tag, with the same CSS applied to the regular FB Login buton.
So essentially, if the user is already connected, we don't really need FB's intervention for authentication, we can just do whatever we want (request perms, redirect, etc).
That should work.
Unfortunately i have higher priority things i need to work on, but it sounds like this is top priority for you.
So give that a go, hope it helps.