ftdeveloper
ftdeveloper

Reputation: 1093

Change content dynamicly in google chrome extension development

I have login form in chrome extension. I check if username and password true. I want if user loggined in extension content (html page ) must be change. And after that when i clicked extension logo i dont want user see login page. How can i do that?

Upvotes: 0

Views: 85

Answers (1)

Methos
Methos

Reputation: 14334

Your question is not very clear. But seems like you want to simply display different HTML page depending on whether a user has logged into your extension.

A simple way to do that is, make user first login to your extension. Define some variable like "logged-in-state", initialize it to "not-logged-in". Change it to name that the user logged in with after successful login. Flush this information to localStorage.

Next time when your extension starts, read this variable from the disk.

Every time, any page from your extension loads, make it send a message to background script requesting for that variable. If the value is "not-logged-in" then display login/password. Otherwise, display regular content.

Basically, assign various classes dynamically to HTML content for different states like logged-in/not-logged-in and have CSS rules that will hide based on the class value.

Upvotes: 1

Related Questions