html - JSON - Get Chrome Tab Title -


my chrome extension loads local .html file.

(inside manifest.json file)

"default_popup": "popup.html", 

inside html file, frame created www.website.com, therefore being able view www.website.com in little popup extension creates (using popup.js).

<iframe src="http://www.website.com" width="100%" height="100%" frameborder="0"> 

i chrome extension change "www.website.com" add onto end of title of current tab chrome user viewing, minus spaces , reducing length maximum of 30 characters.

example: bob has chrome open www.pbs.org, has title "pbs public broadcasting service". clicks chrome extension , drops down, showing him www.website.com/pbspublicbroadcastingservice in dropdown window. bob pleased.

here screenshot of popup looks like: http://julianapena.com/wp-content/uploads/howtobuildachromeextensionpart3loadingan_13ea3/image_thumb.png

according https://developer.chrome.com/extensions/tabs

you can add "permissions": [ "tabs" ], in manifest file, in helper.js file add

function getcurrenttab(callback) {   chrome.tabs.query({ active: true, currentwindow: true }, function (tab) {     tab = tab[0];     return callback(tab);   }); } 

, , add in popup.js

function init() {   getcurrenttab(function(tab) {     showiframe(tab.title);   }); }  document.addeventlistener('domcontentloaded', init); 

also can create chromeui.js can define showiframe function.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -