chrome extension dynamically add javascript
JavaScript
//inject another js file from content script w/ callback
function injectScript(file, node,callback) {
var th = document.getElementsByTagName(node)[0];
var s = document.createElement('script');
s.setAttribute('type', 'text/javascript');
s.setAttribute('src', file);
s.onload = function() {
callback();
};
th.appendChild(s);
}
injectScript(chrome.extension.getURL('myscript.js'), 'body',function(){
//mysript.js is done loading
});// content script
chrome.runtime.sendMessage({
injectScript : true,
filename:'/scripts/myfile.js'
}, function(response) {
if(response.done) {
//handle something when script is done
}
});
// background script
chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) {
if(message.injectScript){
chrome.tabs.executeScript(sender.tab.id, {file: message.filename}, function() {
sendResponse({ done: true });
});
return true; // Required for async sendResponse()
}
});
Also in JavaScript:
- Title
- d3js circle out of scrren
- Category
- JavaScript
- Title
- expo open app settings
- Category
- JavaScript
- Title
- copy object javascript
- Category
- JavaScript
- Title
- create dice game javascript
- Category
- JavaScript
- Title
- hide element by name javascript
- Category
- JavaScript
- Title
- how to create duplicate key array in javascript
- Category
- JavaScript
- Title
- all fields entered jquery enable submit button
- Category
- JavaScript
- Title
- console.log('Hi there!');
- Category
- JavaScript
- Title
- access to static file nodejs
- Category
- JavaScript
- Title
- add elements to an array with splice
- Category
- JavaScript
- Title
- console.log in jsx
- Category
- JavaScript
- Title
- declare multiple variables javascript
- Category
- JavaScript
- Title
- format a date moment
- Category
- JavaScript
- Title
- dotnet core ajax post of an ojject site:stackoverflow.com
- Category
- JavaScript
- Title
- go to page jquery
- Category
- JavaScript
- Title
- angular generate component
- Category
- JavaScript
- Title
- dom create element
- Category
- JavaScript
- Title
- how to code print in javascript
- Category
- JavaScript
- Title
- how to set height of material ui dialog react
- Category
- JavaScript
- Title
- creating js objects
- Category
- JavaScript
- Title
- Cannot set property 'innerHTML' of null
- Category
- JavaScript
- Title
- anagram javascript example
- Category
- JavaScript
- Title
- cant find variable react
- Category
- JavaScript
- Title
- get a element using name in jquery
- Category
- JavaScript
- Title
- async await javascript
- Category
- JavaScript
- Title
- comparing arrays javascript
- Category
- JavaScript
- Title
- express get url parameters
- Category
- JavaScript
- Title
- get attribute value jquery
- Category
- JavaScript
- Title
- blur javascript
- Category
- JavaScript
- Title
- html inline javascript
- Category
- JavaScript
- Title
- accept 2 values after decimal in angular forms
- Category
- JavaScript
- Title
- checked unchecked through js
- Category
- JavaScript
- Title
- get client timezone offset JavaScript
- Category
- JavaScript
- Title
- boucle for in js
- Category
- JavaScript
- Title
- iframe reload parent page
- Category
- JavaScript
- Title
- if str contains jquery
- Category
- JavaScript
- Title
- how to add script before </body> in magento 2
- Category
- JavaScript
- Title
- how to add javascript to html
- Category
- JavaScript
- Title
- enable disable click on div jquery
- Category
- JavaScript
- Title
- for of loop syntax javascript
- Category
- JavaScript
- Title
- create bottom navigation bar react native
- Category
- JavaScript
- Title
- hamster js
- Category
- JavaScript
- Title
- async await catch error
- Category
- JavaScript
- Title
- filter array objects javascript
- Category
- JavaScript
- Title
- how to know which button clicked in javascript
- Category
- JavaScript
- Title
- append array js
- Category
- JavaScript
- Title
- express get params after ?
- Category
- JavaScript
- Title
- document delete element
- Category
- JavaScript
- Title
- javascript Compare two arrays regardless of order
- Category
- JavaScript
- Title
- javascript array to comma separated string
- Category
- JavaScript
- Title
- dotenv not loading process.env in node
- Category
- JavaScript
- Title
- express server replit
- Category
- JavaScript
- Title
- javascript array remove duplicates
- Category
- JavaScript
- Title
- if clicked outside of div jquery
- Category
- JavaScript
- Title
- bootstrap datepicker format dd-mm-yyyy
- Category
- JavaScript
- Title
- display none after hover
- Category
- JavaScript
- Title
- html to json
- Category
- JavaScript
- Title
- how to get the size of the window in javascript
- Category
- JavaScript
- Title
- JavaScript append text to div
- Category
- JavaScript
- Title
- Adding and Deleting html Elements
- Category
- JavaScript
- Title
- Angular watching for changes in $http.pendingRequests from directive
- Category
- JavaScript
- Title
- how to return an object in javascript
- Category
- JavaScript
- Title
- for loop inside a for loop javascript
- Category
- JavaScript
- Title
- iterate through array javascript
- Category
- JavaScript
- Title
- javascript check if string contains substring
- Category
- JavaScript
- Title
- angular reactive forms
- Category
- JavaScript
- Title
- audio get current time
- Category
- JavaScript
- Title
- enter event in jquery
- Category
- JavaScript
- Title
- javascript check if array is empty
- Category
- JavaScript
- Title
- add class jquery
- Category
- JavaScript
- Title
- angular attach component to body
- Category
- JavaScript
- Title
- custom status discord bot
- Category
- JavaScript
- Title
- get browser timezone javascript
- Category
- JavaScript
- Title
- how to square a value in javascript
- Category
- JavaScript
- Title
- delete js
- Category
- JavaScript
- Title
- get value javascript
- Category
- JavaScript
- Title
- eval in js
- Category
- JavaScript
- Title
- if (req.url === "/script.js")
- Category
- JavaScript
- Title
- how to name a javascript variable
- Category
- JavaScript
- Title
- download jquery
- Category
- JavaScript
- Title
- empty array js
- Category
- JavaScript
- Title
- find intersection between two object arrays javascript
- Category
- JavaScript
- Title
- 2gis nuxt
- Category
- JavaScript
- Title
- javascript are arrays equal
- Category
- JavaScript
- Title
- how to read an array in javascript in HTML5
- Category
- JavaScript
- Title
- flip a coin javascript
- Category
- JavaScript
- Title
- get page resolution jquery
- Category
- JavaScript
- Title
- html decode javascript
- Category
- JavaScript
- Title
- javascript change meta tag
- Category
- JavaScript
- Title
- drupal 8 node has field
- Category
- JavaScript
- Title
- how to add changes every time you route navigate to page in angular
- Category
- JavaScript
- Title
- angular two way property binding
- Category
- JavaScript
- Title
- how to add role in discord.js v12
- Category
- JavaScript
- Title
- chart.js label word wrap
- Category
- JavaScript
- Title
- how to deep copy object in javascript
- Category
- JavaScript
- Title
- callback in response node.js
- Category
- JavaScript
- Title
- compile angularjs template
- Category
- JavaScript
- Title
- combine two arrays javascript
- Category
- JavaScript
- Title
- chrome extension dynamically add javascript
- Category
- JavaScript
- Title
- add element to body javascript
- Category
- JavaScript