Activity › Forums › Salesforce® Discussions › When developing a Chrome Extension, how to determine if it is running for the first time?
-
When developing a Chrome Extension, how to determine if it is running for the first time?
Posted by shafali on April 14, 2016 at 7:59 AMWhen developing a Chrome extension, how to determine if it is running for the first time?
shariq replied 7 years, 7 months ago 4 Members · 4 Replies -
4 Replies
-
You can listen to the runtime.onInstalled event.
Please refer here https://developer.chrome.com/extensions/faq#faq-lifecycle-events for more information.
- [adinserter block='9']
-
Here is my json and js file that am using:
manifest.json:
{
“name”: “MyExtension”,
“version”: “1.0”,
“description”: “Bravo watch videos here!”,
“permissions”: [“tabs”, “http://*/*”],
“content_scripts” : [{
“matches” : [ “www.youtube.com/*”],
“js” : [“shafali.js”]
}]
}shafali.js :
function state() { console.log(“State transit”); }
var player = document.getElementById(“videoPlayer”);
player.addEventListener(“onStateChange”, “state”);
console.log(“Started!”);I am trying to use the above code when developing my chrome extension which is to play youtube videos. But when I see the console the msg shows only ‘Started!’ not ‘State transit’ . What am I doing wrong?
-
function state() { console.log(“State transit”); }
var player = document.getElementById(“videoPlayer”);
player.addEventListener(“onStateChange”, “state”);
console.log(“Started!”); -
Hi,
I think you can use – runtime.onInstalled event.
Hope this helps.
Log In to reply.