Chrome Extension launch from website button - javascript

I do have an extension (developed by me). It works fine. However I can't get the idea on how to launch extension from regular button on a web-page.
The main action (opens Chrome Popup) is performed when I click on extension icon.
But I also need to be able to launch extension via button click on website.
Should I send a msg to extension from website via javascript or?
Or I can go in a different way, and insert content from extension popup to website placeholder. A bit awkward working with extensions.
Any advice appreciated.
Thank you.

Unfortunately, it's not possible. But from the looks of it, it may be available soon.
Check out this answer in this thread.

Related

Chrome Extension: adding button to header-title area of tabs

I want to develop extension that can reload a web page by clicking on the tub.
Is it possible to add a button to the title area of a web page?
If yes
What should I add to the manifest?
Which object should I use to do so?
Unfortunately, this is not possible. The Google Chrome Extension APIs do not provide any functionality to do this... yet. As of now, your extension can only display page actions on the address bar or browser actions near it along with other extensions.
Page actions:
Browser actions:

Debugging tool for Chrome Extension notification window

I created a notification window using the Chrome Extension API:
var notification = webkitNotifications.createHTMLNotification("notification.html");
notification.show();
Also there is an external notification.js for all the scripts I would like to run in the notification window (Since the manifest version 2 discourages inline javascript). Everything works fine except I couldn't open developer tools for the notification window to inspect the page. I can do it for the background as well as the popup pages, so not sure if I didn't find it or I simply can't inspect notification through the developer tool. I know I can send messages between background and notification so that outputs show up on the console, but it would be nice if I could inspect directly.
Thanks much!
Navigate to chrome://inspect/ and you can see all the pages that can be inspected. Under the section "Extensions" you should be able to see your notification page and you can inspect it.
Adding this answer for completeness, because #JJin's answer may had been working before but not in Chrome versions 24 and 25.
After some experimenting I accidently found that the developer tool is available for the notification page. The trick is to
fire up the notification window first and keep it on;
navigate to chrome://extensions and notification.html should appear alongside the background.html or whatever name the background page's name is,
as shown in the screenshot:
Make sure the notification window is on otherwise the notification.html would disappear.

Possible to run Javascript from address bar (bookmarklet) within Google Chrome's settings panel?

I would like to make a bookmarklet to open google chrome's settings panel and clear my cache with a single click.
For a while now, Ive had a bookmark that opens chrome's settings panel with the 'clear cache' setting already selected. After clicking the bookmark (normally opening it in a new tab) I have to then opent the tab and submit the form. However, when developing this is a task I have to do quite often and these several repeated steps just seem unnecessary.
This link opens the page to clear one's cache (obviously for Chrome users only): chrome://chrome/settings/clearBrowserData#cache
I recently discovered bookmarklets and thought it would be a good way to accomplish the task of clearing my cache with a single click. However, I've discovered that putting even a basic javascript sample in the address bar when on the settings page (linked above) fails to work.
For example, this works in the address bar on any given page, but not from the chrome settings page:
javascript:alert('hello stackoverflow');
Is there a way to execute javascript from the chrome settings page? Are there other options? Im looking for any route to achieve this goal and would love to learn something along the way, even if it means doing some evil. :)
add a bookmark:
javascript:document.write('<form onsubmit="window.open(\'javascript:\'+js_line.value, \'target\');return false;">javascript:<input type=text name=js_line style="width:90%;"/></form><iframe src="" name="target" style="width:100%;height:90%;"/>');
What you want might not be fully possible through a bookmarklet, but it's certainly possible with a Chrome App. There is an app Clear Cache already. I find it pretty useful.

Want to use browserAction and pageAction at the same time

Documentation says we can have only browserAction or pageAction not both. Is there any trick for this? Or as solution is this good idea to use content script and insert button in a page?
There's no mechanism for a single extension to have more than one UI element in Chrome's chrome. You could certainly inject code into a page, and present some UI there, but you won't be able to have both a browserAction and pageAction in a single extension.
You could, on the other hand, have two extensions which communicate with each other via message passing. See chrome.extension.sendRequest for details as to how that might work.

How to make javascript function appear and play on site that i cannot change

Here is the code that i would want to play on one page, imgur in particular, this will click the next button in the gallery i was wondering if i would just have to make my own extension or what
function timeMsg()
{
var t=setTimeout("alertMsg()",3000);
}
function alertMsg()
{
alert("Hello");
}
You could go the way of chrome extensions, or greasemonkey scripts, its really comes down to you not 'doing this on the site' but manipulating your DOM in your browser.
Greasemonkey -- http://www.greasespot.net/
Chrome Extensions -- http://code.google.com/chrome/extensions/getstarted.html
A Chrome extension is probably your best bet. They're really easy to make.
Of course, you can always just paste that code into the console and hit Enter.
I have to use an online time clock for work. I made a bookmarklet that populates the form and submits it. It isn't running on their site, just fiddling with the DOM.
Test your javascript on their site using the developer console
Save a bookmark of the page
edit the newly created bookmark in the bookmark manager and change the URL to something like this
javscript:( your function )();
example

Categories