GeckoFX invoke Javascript from c# for each element - javascript

Google adds a javascript method to each search result (hyperlink).
Search any keyword from google, right click on a link, and copy link location or link address or just mouse down on a link and it will show the complete URL.
I need to simulate the onmousedown from c# to copy the complete link.
This is what Google render in HTML.
Canvas Wall Art Prints ยป Products
This link is shown on mouse down:
http://url/?sa=t&rct=j&q=&esrc=s&source=webhp&cd=1&cad=rja&uact=8&ved=0CDkQFjAA&url=http%3A%2F%2Fwww.canvaswallartprints.com.au%2Fproduct%2Fbonne-nuit%2F&ei=iQJtVZaBCsj8UKDqgMgE&usg=AFQjCNEAuSEgTR2_eYtjFFcXfNEHi8VVeA&bvm=bv.94455598,d.bGQ
There are lots of answers telling how to add events but in above case, the javascript function is already part of document, I just need to invoke it.

I am sharing my workaround to help if anyone else got stuck at same issue.
With GeckoFX I could not manage to invoke JavaScript method so, I had to move this part to WebBrowser control. Iterated HtmlElementCollection to reach the desired hyperlink and used the HtmlElement InvokeMember("onmousedown") to invoke the desired JavaScript function.

Related

How to access the data-eid value from the main Google Calendar page

I am trying to figure out how to access the data-eid for a given Google Calendar event directly from the main view of the Calendar, not from the resulting event edit page that appears when an event is clicked. Each event title is clickable and appears to have a unique div class in the format of "evt-lk ca-elp5"
which, when clicked, runs some minified JS functions and renders the edit page, which does contain the data-eid both in the page URL and within a class inside "coverinner".
Now, the question is, can the data-eid be determined without clicking on the event link to go to the edit page? I have tried parsing through the minified JS code from the calendar page, and attaching to the click event in Chrome's debugger, and haven't had much luck figuring out which function returns the data-eid. I'm hoping someone else has, or that there is a better way to get this info. To be clear, I know how to use the Google Calendar API to get a list of events, and what I'm trying to do is tie those events to their corresponding event blocks on the Google Calendar page, which appear to only have unique class names that don't directly correlate to the underlying event ID.

How to Webstorm search references acquired by jquery selectors?

when you use ctrl+g on a reference, it finds you that within the same file
is there a more global search (all files in project) that finds direct references as well as as those places where jquery is invoked to get a reference to the object?
You can check the event that is occurring on any button or any html element when clicked.
All you need to do is instead of searching it right in the webstorm you can trace it accurately in the firebug.
Please make sure that firebug is installed or open the default developer's tool in your firefox or chrome browser.
To see the event that is occurring on an element :
right on the element and inspect it.
firebug will open up at the bottom of the browser and in the right-bottom corner you will find a box in which there are different tabs.
click on the events tab
you will see events such as click,mousehover....etc.
check the function that is getting called by clicking on that function name and it will show you the line of code that is being executed when you click that particular element with the js file name and the line number.
Hope that helps you out.

Fire several flash buttons on a single click

I'm using Zero Clipboard and Downloadify to put certain data into clipboard and call Save As dialog. I want to avoid having to click two buttons, but Flash does not allow taking action with simulated click() from Javascript, only real mouseclicks. Is there a way to "spread" a single click done by user to two flash buttons?
I think I heard somewhere that a click can reach through several layers of elements. I tried putting the two buttons one on top of another (by calling ZClip on the flash object that Downloadify generates), but it doesn't work, only the upper button fires (ZClip), even though the bottom one is able to detect mouseover (changes button color).
I need this for a userscript I'm writing for myself to enhance functionality of an online photoalbum. The idea behind the script is that it tries to guess the category of a currently opened image based on its filename or tags and generates a full path under which I would want to save this image, which is then placed into clipboard so that upon saving I can simply paste it to the filename field saving me the trouble of having to navigate to the desired folder manually every time. Since I'm going for decreasing the amount of clicks, I'd like to have both clipboard operation and Save As dialog to happen at a single click instead of click for copy and right-click for context menu and click to choose "save as".
I'm using Opera 12.17 if it matters.
Edit: It looks like you can call a flash function from outside by Javascript via SWFObject plugin, but that function needs to be declared as external in flash code. I tried looking up the list of available functions in my case, ZClip has none and Downloadify only has unrelated stuff like show/hide/classes, so still no luck.
ZClip has the ability to relay the click event to the object it's glued to, which is on by default, but that still doesn't work in my case, even though I glue it to Downloadify.
Apparently it's impossible, I asked the same question in several places online and got no solution anywhere.
Still, I solved the problem another way, if I can't fire two buttons at once, I should just add the functionality of one into another. Which I did, adding the ability to copy to clipboard to Downloadify, works perfectly.

Turn off JavaScript notifications in IE9 and FireFox4

In web development, JavaScript is often executed when clicking on elements.
In both Internet Explorer 9 and FireFox 4 a little message pops up in the bottom left hand corner with the JavaScript function will be executed by clicking on elements these elements.
ASP.NET makes use of the JavaScript __doPostback(...ugly parameter names..) on almost every element that sends a request to the server. This JavaScript is automatically added to the HTML elements that are generated by the ASP.NET controls and I have no way to circumvent this.
For example, an ASP.NET DropDownList is rendered as an HTML Select element and the __doPostBack() method is added to it so that whenever the user selects a new element, the server can process this action.
The __doPostaback() method is embedded into many of the ASP.NET controls and there is no easy way to change this.
One of my end users commented that this new feature makes it feel as if they are in "Debug-mode"....
So, my question is: how do I either make this popup show something user friendly...or is there a way to tell the browser (via HTML) not to display this nastiness?
Thanks!
-Frinny
Why don't you make the href of the link a hashtag and attach the actual action via JavaScript:
HTML
<a id="foo" href="#foo">Foo</a>
JS
var foo = document.getElementById('foo');
foo.onclick = function(e){
//script foo!
return false;
};
Your location will still be #foo to look nice, but the actual action will be in the foo.onclick function.
Alternatively you can specify the event inline (Foo), but I try to keep a clear MVC separation with HTML, CSS, & JS.
Using a hashtag also gives you the ability to listen for hash-change events or check the hash tag onload so that a user can still middle-click a link and have it work correctly in a new tab.
To my knowledge there isn't a way to make it not display, as that is part of the browser and not the page.
What I would do is create javascript functions at the top of the page with user readable names that contain the other functions inside.

Firefox add-on that will count number of clicks at listed urls

I'm trying to write Firefox add-on that will follow users activity for chosen web links at some webpage. Because I'm not so familiar with web development, I would appreciate your suggestions and directions how to finish this task.
I already made one simple Firefox add-on, but yet don't have idea how to mark wanted links and how to make counter for clicks at that (chosen) links. Probably I need to add function in JavaScript file that will be placed in content folder and called within html file, but I need your help how to locate wondered web link? I.e. do I need to locate it using Element ID (and how to do it) or there is some other way?
Also, if somebody knows similar add-on that is already written, that would be perfect!
Thanks in advance!
Nemanja
Essentially, you just need an event listener listening for the click event. You could call content.document.addEventListener('click', myListener, true); every time a page loads, or you could just call gBrowser.addEventListener('click', myListener, true); when the whole program starts up. Either way, myListener will be passed the click event as an argument, so then you can do something like:
function myListener(event) {
if (event.target.href && event.target.href === 'some.url.com')
updateCounter();
}
I hope this makes sense.

Categories