I want to find if the url is being accessed is entered by the user or if its something that's being loaded in the background due to other reasons. This information is available through the transaction qualifier that's available in chrome.webNavigation.onCommitted. I want to add this as an additional header information in chrome.webRequest.onBeforeSendHeaders.
However, onCommitted is fired after onBeforeSendHeaders.
Is there any other way to get this information before OnBeforeSendHeaders is fired? I tried chrome.tabs.getCurrent in webNavigation.OnBeforeNavigate, but the callback doesn't have any info in the returned tab object (its undefined).
Any help will be appreciated.
Related
We have currently an order confirmation page on our website after the customer paid where information is sent to our analytics tools.
If the customer refreshes the page, the information about his order is sent again to our analytics tool and then we get wrong/duplicate information in our orders statistics.
Is there an easy way to prevent this?
The goal would be here to not trigger the custom html tag when the customer reloads the page.
It should be only fired once.
Thanks!
Best,
Victor
You can use PerformanceNavigation.type or PerformanceNavigationTiming.type respectively in a Javascript variable to find out if the page has been reloaded (the former is already marked as deprecated while the latter is still marked as experimental, so to be on the safe side you should probably check which one is supported by the browser and use that).
Then use the return value to detect reloads and block the tag depending on that.
An alternative would be to set a cookie or local storage entry with the transaction and block based on that.
We finally found another solution that seems to work: We used an additional trigger in GTM that prevent the info to be sent twice.
When calling the page for the first time, the condition is set to "false", and on each following request to that page it is set to "true".
We made some test orders and it seems to works correctly. Thanks!
I am working on a firefox addon that will automatically populate the login form fields and login. What I have access to could be anything from id's classes' or the xpath to the login button depending on what the website gives. The priority captured will usually be id's if they exist. The specific website that won't trigger the click is: https://login.paylocity.com/escher/escher_webui/views/login/login.aspx
I tried using $(element).trigger('click') or $(element).click() and they both don't trigger the click automatically. The error in the console log shows:
XrayWrapper denied access to property callee (reason: value is callable). See https://developer.mozilla.org/en-US/docs/Xray_vision for more information. Note that only the first denied property access from a given global object will be reported.
I also tried the Javascript method shown here: Is it possible to trigger a link's (or any element's) click event through JavaScript?
That doesn't work either.
XrayWrapper denied access to property callee
This suggests that the script is running in an environment that has higher privileges than the page content itself, which in turn results in some security barriers (the xray wrappers in one direction, access denied errors in the other) since the caller now is partially privileged code which content is not allowed to access.
Instead of using jquery you could try manually synthesizing a DOM event and firing it, possibly by accessing the unsafe window.
Something along the lines of new window.wrappedJSObject.MouseEvent("click"), same for dispatchEvent().
Alternatively you could also try firing a submit event on the form instead of a click event.
Yet another approach is to make .callee accessible by transplanting the calling function into the content window.
I'm trying to create an extension from chrome which monitors a specified cookie and takes action when its value is overwritten. I'm aware that the cookies library has an onChanged() event listener but I don't know how to use for specific cookies.
For example, if I visit google.com, it stores a cookie called "NID"-- how do I make an event listener specifically for it?
From the documentation, it doesn't seem like you can monitor individual cookies. What you can do, however, is check the cookie after the callback is fired to determine whether to take action.
Since the callback is passed a changeInfo parameter containing information about the cookie and the reason for the change, you can just check that and fire another function if necessary.
i have been working on trello api so my issue is that i have to save a token in database.
response is in post message :
window.opener.postMessage("token generated here ", "http://www.servername.com")
1. how to fetch token from post message.
2.i have tried code from this link :http://stackoverflow.com/questions/3332532/how-can-i-do-cross-domain-postmessage. but is not working.
3. https://developer.mozilla.org/en-US/docs/Web/API/window.postMessage this link i also go through .
snapshots step by step here is
step 1: authentication with oath :http://postimg.org/image/5cwazfvfv/
step 2: when i press allow button to get token i recieve this window and here
url: http://postimg.org/image/f3y34m2dz/
As I know, postmessage is asynchornious. Consequently, it's hard to capture which message is returned to which source parent/window. I think we can consider 2 things as below:
It's reasonable define how to determine which target window (instead of "*" indicator). In my case, we can temporary use like that: frameA.contentWindow.postMessage(msg, frameA.src). However, my solution still face problem if we need to support many frame has the same href.
The second thing is needed to point out which target page will received/handle returned value from frame. As above thing, my solution is rely on origin property of event object (used for Chrome/Safari browser for instance. In case other versions/browser, we need use corresponding property).
Could anyone clarify how the GA actions _gaq.push(['_link', <href>]); and _gaq.push(['_linkByPost', <form>]); work?
I'm not interested on how to use them as presented in the documentation. I understand those scenarios. I want to know more about what they do when called.
Edit:
I suspect how this works but I need some confirmation from someone that fiddled with this longer than me. I want to know what the process is in each of the cases in small steps. I know that it changes the sent data in order to overwrite to cookie on the target site, but I need to know exactly the actions that happen (in terms of JavaScript on the sending page) after you do the push.
I would also like to know if I could use _gaq.push(['_link', <href>]); from anywhere in my code to change the page.
Thank you,
Alin
We will assume _gaq.push(['_setAllowLinker', true]); used on any needed page.
What _gaq.push(['_link', <href>]); does:
Appends the __utm<x> cookies to <href>. You need to return false in the onclick of the anchor so that the original link does not follow through.
Changes the browser location to the newly formed URL.
What _gaq.push(['_linkByPost', <form>]); does:
Changes the action attribute of <form> so that it includes the __utm<x> cookies.
What happens on the target page:
The GA script on the target page checks the received parameters and if the __utm<x>s are sent it overwrites its own cookies with these. This results in identifying the user as being the same on that left your original page.
As a bonus _gaq.push(['_link', <href>]); can be used in (almost) any situation window.open(<href>); can be used.
They pass the cookie information from one domain to another; in the instance, it does this by appending a query string on the next page; with _linkByPost, it sends the cookie information as GET parameters on the form action along with your POST data.
If _setAllowLinker is set to true on the target page, the cookie information sent will overwrite the default Google Analytics cookies on the target page, and will allow for linked, consistent session information between the two, as the cookies will ensure that consistent data is shared.
EDIT:
No, you can't call it from anywhere in your page, unless you bind it to an onclick of where you'd like it called.