How to make a form-filling google chrome extension - javascript

I was wondering if anyone could provide me with some links to some tutorials or explain (with some example code), how I would go about making a simple google chrome extension (or in any programming language or browser if that is impossible), how I would make an extension that can visit a specific site, fill a login form on that site, click some links and then do the same sort of thing on the linked to site.
Thanks

Personally, I would not use a chrome extension, but maybe a perl script. There is an extension called WWW::Mechanize that is designed exactly to do this kind of stuff.
You can find plenty of tutorials and examples, just google it.
Edit in 2021: the above recommendation has become a bit outdated since 2013. For a more up-to-date take, I'd still recommend a scriptable headless browser instead of an extension for most automation tasks, but probably not WWW:Mechanize. There are good lists of options, such as this one.

Related

How to get title/url of tab while detecting tab change using JavaScript

Detecting Tab Change using javascript can be done easily using page visibility API as it is mentioned in this answer
Is there some way to get the information about the changed tab like the title of the tab/URL etc using javascript, jquery, or any other method?
For (obvious) security and privacy reasons this is not possible on any modern browser I am aware of.
But since you asked for any other methods, you could achieve this pretty easily with a browser addon and the tabs api.
Nope, Javascript interacts with web APIs that the browser has installed on it.
So in order to do this, there would have to be a way within one of the installed APIs to do this. Which I highly doubt there is. Also, Most browsers effectively run the DOM in a contained sandbox meaning that javascript and the web APIs can only access things from within its sandbox aka tab.
That said, it doesn't mean it's impossible. There may be an exploit in one of the API's allowing you to get other browsers info not usually available to you.
Feel free to crawl through all the web api docs to find an exploit and also try to engineer a way to break out of chromes tab sandboxing architecture via javascript.
I won't say it's impossible but it's highly unlikely unless someone makes a big mistake on a future release of chrome and one of the direct to browsers api's has an exploit. Sounds like a lottery win scenario to me just to read a tab.

lean&fast way to make an addon work for all major browsers? firefox,chrome,[opera,internet explorer,safari]

Yet there are tools to make one addon for all major browsers at once,
see: crossrider, kangoextensions and http://besttoolbars.net/products/addon_framework
With greasemonkey and a converter to a full firefox addon,
i already made an addon, that does the following three simple things:
check http status of external links with wiki.greasespot.net/GM_xmlhttpRequest,
(which won't work out with javascript alone as of cross-site-scriting policy.)
manipulate the current page/dom through some regex
inject an additional hosted javascript for automatic updates
but is there any "cross-browser addon maker" capable of the 3 things above?
(especially http to external links like GM_xmlhttpRequest)
and open source, free or at least free of their branding in the addons made with it?
or else what is the easierst way from my greasemonkey script to full addons for also
chrome,[opera,internet explorer,safari(or more)].
(i imagine this alone could be a few kb of code to match the requirnments above and doesnt need to be a complex service like crossrider?)
Thanks!=)
I think you can achieve your goals using the Crossrider platform, writing code once in JavaScript that works on all supported platforms. For your specific goals, you can use the appAPI.request API for your HTTP requests and jQuery/JS DOM to manipulate the page content.
Regarding branding, the Crossrider platform enables you to customize the extension using your own image, specify your own post-installation landing page (Thank You page), and either host a seamless installer widget on your site OR host a Windows installer file, and hence an end user does not see any Crossrider branding at all.
Finally, regarding monetization, we have a strict policy of only monetizing extensions with the mutual consent of the extension developer.
I hope this clarifies your concerns, but please feel free to ask any further questions either on this thread or by contacting our support (support#crossrider.com).
Disclaimer: I am a Crossrider employee

What's a simple way in Google Chrome to insert Javascript into sites?

I would like to be able to add custom snippets of javascript to any site that matches a regex. This is mostly because of sites that I use daily because of specialized content, but which have a poor design. I want to be able to do something like:
Visit site See that sidebar overwrites content
Whip out developer tools, find div id for sidebar
Edit a snippet of javascript which is executed on document.ready for this domain:
$('#sidebar-right').remove();
A bit of searching for user scripts tells me that I need to be writing a Chrome extension, which seems unfortunate and overkill. Is there not an easier way, or an extension which is nothing but a javascript editor that assigns snippets to domains? I'd really like to be able to edit in Chrome itself, or at least have a file that I can just leave open in MacVim all the time. An extension requires unloading/installing to update as far as I can tell.
If I just had one big javascript file, that would be fine. I'd just wrap my customizations in domain checks.
Bonus love if I can write in CoffeeScript.
The answer is to use the Tampermonkey chrome extension.
https://chrome.google.com/webstore/detail/dhdgffkkebhmkfjojejmpbldmpobfkfo
Why not dotjs http://defunkt.io/dotjs/ ? It's local, you can version it with git, you can easily take it to another computer...
Another alternative that neatly solves the problem is Custom JavaScript for websites. You just need to install the extension, which takes around 2 seconds, and then you can immediately start typing your custom JavaScript for the specified website.
The extension automatically recognizes the current website, so all you need to do is write your code and click on Save. You can also easily import jQuery or your external scripts for convenience.
Custom JavaScript for Websites 2 is an alternative to Custom JavaScript for Websites, with some bug fixes and sync scripts across devices feature.
Snippets are available directly in Chrome Devtools
https://developers.google.com/web/tools/chrome-devtools/javascript/snippets
Witchcraft is another Google Chrome extension for loading custom Javascript and CSS, and it is supposedly for more avanced users. The older dotjs project repository lists Witchcraft as its successor.
What you're looking for is Greasemonkey. But wait, Greasemonkey is for Firefox only, right? Turns out, you can install Greasemonkey user-scripts as native Chrome add-ons. Just go to userscripts.org and hit the Install button on one of them, and Chrome will automatically convert it into a native add-on. Then, write your own and install it using Chrome.
Note: This only works in Chrome 4.0.

Help needed on writing extension for Google Chrome/Mozilla

I would like to create a extension for Google Chrome/Mozilla for the following requirement.
If I search for any text in a web page, If text is found then automatically background colour has to be added to that text.Basically it will be done by browser. But multiple searches are possible. So I need to make all the searched and found texts highlighted. I know very basics of writing extensions for Google chrome( I have learnt through http://code.google.com/chrome/extensions/getstarted.html ) . I have good knowledge on JavaScript. I don't have any basic idea to achieve the solution for my requirement. Please someone guide me on how to proceed further.
Although I don't have an answer for Google Chrome, making a Firefox addon is simple.
Take a look at the addon SDK and addon builder and the documentation for it. The first tutorial outlines the setups you will need to take and it should help get you started. Also, ou will probably need the page-mod library.

How to make a firefox addon that acts as an offline website

What I want to do is that when the user clicks a button I will add to firefox (or clicks an option I will add under tools, etc), a new tab should be opened, and in the tab will essentially be an offline website that is written in HTML/CSS/JS and will be part of the addon.
How can I do this? It does not matter to me if I require a very new version of firefox to accomplish this.
Making your first firefox addon can be quite challenging, at first. But once you make one, things get much better. Here are some tools to help you get started:
https://addons.mozilla.org/en-US/developers/tools/builder
I suggest you start with this and check all the features. Once you download the skeleton, look over ff-overlay.xul in the /chrome/content folder. It should be straightforward if you know XUL/Javascript.
https://developer.mozilla.org/en/Setting_up_extension_development_environment
This link helps you set up Firefox for easy addon testing and debugging.
https://developer.mozilla.org/en/Code_snippets/Tabbed_browser
The Mozilla Developer Network is incredibly useful. For example, that link takes you to a page that explains everything about switching tabs.
https://builder.addons.mozilla.org/
Addon playground.
Remember, Google's your friend! Good luck!

Categories