chrome extension options change default popup.html - google-chrome-extension

I have a chrome extension where the popup.html simply has an iframe that loads a page.
I want to allow users to select their language, and as I'm helping a charity do this each language page is very different as they need very different content based on the country!
Therefore, I can't just replace some of the fields like the google developer page example does; I need to change the page that is loaded in the iframe.
e.g. In my directory where the pages are stored I have english.html, german.html, spanish.html all of which are completely different pages.
By default the english.html page loads in the iframe, but the user should be able to go into the options file and select german so when they click on the extension the german.html loads by default every time.
Here is the jsfiddle showing what I currently have in the popup.html, and the popup.js:
http://jsfiddle.net/hemang2/EDV82/
You'll see the flickr API being called, but that's only there because I wasn't sure how to get rid of it!
So essentially my question is how to link the options file to change the default url loaded in the iframe.

Use the setPopup method: http://developer.chrome.com/extensions/browserAction.html#method-setPopup
It allows you to set any html file as your popup.

Related

Browser Console - How to include javascript code on every page redirect?

Is is possible to load special javascript code (created by me) to my browser console (mozilla firefox) on every redirect page? I want to create a special script-robot, which will be do special actions on some website. For example:
Click button: "Add new advert"
... NOW IS REDIRECT
Write to input[name='title'] advert title
Write to input[name='description'] advert description
Click button: "Add now!"
... NOW IS REDIRECT
Click button: "Logout".
So I want to include my own javascript code to my console and I want automatically reinclude this file on every page redirect. Is is possible?
Thanks.
yes, it is possible. What you would do is create your own google extension with links to a js file to run. Here are some instructions on how to make said extension.

Google Chrome Extension get DOM from another page of the site

I am dveloping my first extension and I am currently getting data from the page but the page is for example: "example.com/my-data" and I need to display this data from "example.com/" to not need go to that page. How can I get the data from the home page?

how to load iframe using contentscript and override xframe

First of all, is there another built in way to do this like webview is in phonegap, so I can load an external site into a div or div like element. I know webview exists for chrome apps, but i couldn't find anything for extensions.
Basically i want to show preview of pages on links..
To do that I am trying to load urls of links using by setting src of iframes using content script. However, for most urls, I get an error that xframe not allowed.
what are my options.
xframe is pretty full proof, however, if you aren't referring to specifically an iframe, you could always use a web-proxy such as node-unblocker for node.js, or miniProxy for PHP.

chrome extension css on localhost

I'm working on a chrome extension. The content has a stylesheet content.css. When I run the extension on an external site, it applies the style sheet. When I open a page on my "hello world" page on localhost, it applies the content.css styles initially but the styles go away if I refresh the page and I cannot get them back unless I refresh the extenstion.
Can't figure out why this is but I need to get this resolved.
Thanks,
Ken

Can I access the content of an iframe in JavaScript that is part of a Google Chrome extension?

I have an iframe within the main window named "test_iframe". I want to access the content of "test_iframe" within a Google Chrome extension. I understand that I can do this if I have requisite permissions given in manifest.json.
Can I access the content of this iframe from a background HTML page? Or can I access it in a content script which is part of that extension? (In the latter case I suppose I have to pass the iframe content from the content script to a background page as part of a message for further processing(?))
Let's say this test_iframe comes from http://frame.example.com. I would just inject a content script directly to frame.example.com (instead of the parent page) and do everything there.

Resources