I am making a chrome extension to find all links in a page I am using a browser_action
. I am getting a bug on when you refresh the page, the chrome extension automatically triggers the javascript code. How would I make it so that if you hit the refresh on the browser the extension doesn't trigger? I only want it to work when the click the little icon on the toolbar.
This is how my manifest looks like
{
"name": "Find all first",
"version": "1.0",
"description": "Find all Linkes",
"browser_action": {
"default_icon": "icon.png",
"popup": "popup.html"
},
"icons": {
"16": "icon.png",
"128": "icon-big.png"
},
"permissions": [
"tabs",
"http://*/*",
"https://*/*"
],
"content_scripts": [ {
"matches": ["http://*/*", "https://*/*"],
"js": ["content.js"]
}]
}
I am then calling this in my popup.html
chrome.tabs.executeScript(null, {file: 'content.js'}, function() {
console.log('Success');
});
You can automatically install (force-install) specific Chrome apps and extensions for users in your organization. Users then see these apps and extensions when using Chrome on managed devices or accounts.
Click on the puzzle piece icon, then on “Easy Auto Refresh”. In the popup window, enter the number of seconds after which you want the page to refresh, then click “Start”. The page will automatically refresh every time the timer you set expires.
You can store arrays directly.
Because you have contents_scripts
defined in your manifest, content.js
is being run as a content script every time a page is loaded that matches your matches
(so, any webpage really).
To only run content.js
on the page when the user clicks your Page Action button, remove the content_scripts
section from your manifest, so that no scripts are run automatically. Then, when the Page Action button is clicked, popup.html will execute content.js
as it should.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With