Skip to content

Instantly share code, notes, and snippets.

@philipz
Last active August 29, 2015 14:22
Show Gist options
  • Save philipz/c3d5d95bdbdcab8f2144 to your computer and use it in GitHub Desktop.
Save philipz/c3d5d95bdbdcab8f2144 to your computer and use it in GitHub Desktop.
Chrome Extensions Notes

From The activeTab permission

manifest.json

{
  "name": "Page Redder",
  "version": "2.0",
  "permissions": [
    "activeTab"
  ],
  "background": {
    "scripts": ["background.js"],
    "persistent": false
  },
  "browser_action": {
    "default_title": "Make this page red"
  },
  "manifest_version": 2
}

background.js

// Called when the user clicks on the browser action.
chrome.browserAction.onClicked.addListener(function(tab) {
  // No tabs or host permissions needed!
  console.log('Turning ' + tab.url + ' red!');
  chrome.tabs.create({url : 'http://www.everfine.com.tw'}, function(tab) {});
  /*chrome.tabs.executeScript({
    code: 'document.body.style.backgroundColor="red"'
  });*/
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment