O código abaixo possibilita que você crie uma extensão para o Google Chrome para injetar código HTML em uma página da web. Para baixar o código fonte clique abaixo: Background.js // this is the background code... // listen for our...

O código abaixo possibilita que você crie uma extensão para o Google Chrome para injetar código HTML em uma página da web. Para baixar o código fonte clique abaixo: Background.js // this is the background code... // listen for our browerAction to be clicked chrome.browserAction.onClicked.addListener(function (tab) { // for the current tab, inject the "inject.js" file & execute it chrome.tabs.executeScript(tab.ib, { file: 'inject.js' }); }); Inject.js // this is the code which will be injected into a given page... (function() { // just place a div at top right var div = document.createElement('div'); div.style.position = 'fixed'; div.style.top = 0; div.style.right = 0; div.textContent = 'Injected!'; document.body.appendChild(div); alert('inserted self... giggity'); })(); Manifest.json { "name": "Injecta", "version": "0.0.1", "manifest_version": 2, "description": "Injecting stuff", "homepage_url": "http://danharper.me", "background": { "scripts": [ "background.js" ], "persistent": true }, "browser_action": { "default_title": "Inject!" }, "permissions": [ "https://*/*", "http://*/*", "tabs" ] }
Seja Membro Gratuítamente

Assine a newsletter para receber em seu email as publicações atualizadas neste blog

Top