Is it possible to use LocalStorage in a Chrome app? - javascript

I made an html page that I was going to make an app for Chrome. When I packaged it and tested it, it didn't work. I saw that the error message said that I couldn't use localStorage, but I had to use chrome.storage instead. I built the entire thing around localStorage so using chrome.storage I would have to rewrite large portions of the code. I would like to know if there is a way that I can use localStorage without giving me an error message. I've already tried using an iframe, but it didn't work. I also want my app to open in its own window. Any answers would be appreciated.

Related

Vue.js page inside iframe not showing on Firefox

We have a Vue.js page contains a Echarts pie draft, and we want to show it in another project, which is using jQuery.
It shows perfectly both on Chrome and IE, but on Firefox there's nothing showing.
We tried to replace the Echarts page with some basic numbers in the template, but it's still empty in Firefox.
This is what it looks like in chrome:
And this is Firefox, which only has an empty app tag:
Any help would be appreciated.
edit:
I'm using Firefox93 on 64bit, there are no errors showing in the console.
This is how we inserted the iframe:
Is the website you're trying to load the iframe in secure (https)?
I see you're trying to iframe an http url
Unlike HTTP images in an HTTPS page, which are allowed through with a little warning on the padlock, iframes are considered potentially dangerous active content and HTTP iframes won't be loaded into an HTTPS page.
Besides that the same-origin policy might have something to do with it
When it comes to several browsers is working well, and when opened in another browser it has something wrong, It should be the Web API or Browser API used by the library, in this case, VueJS.
The possible solutions from the estimated source of the problem are:
Update the VueJS to the latest version.
I hope this forum is useful: https://forum.vuejs.org/t/iframes-in-vue/102268, the questionnaire has a problem with its source link. But I think you are not experiencing this. And it is useful for anyone who visited this question.
If the problem is to be solved, I recommended using other people's custom libraries, like this: https://www.npmjs.com/package/vue-iframes. Because those libraries are developed to answer several problems that the creator facing that probably other people would be experiencing too.

what is the meaning of google_experiment_mod in chrome localstorage

I am storing some items in chrome local storage. Along with my variables I can see
google_experiment_mod: "335"
I am wondering what it means.
Below is the code to to store the items and I use chrome developer tool to see the content.
localStorage.setItem("freqInMins", response.freqInMins);
Thanks
google_experiment_mod is used by Google AdSense for experimenting with which advertisement perform best on a website. Please refer to “How Google uses data when you use our partners’ sites”.
I have that too under the web inspector, but only on certain sites. I use mac and I am using Safari. I also found while searching "experiments" in the resource content on the google homepage something that says "dnssec-nd.gexperiments1.com", so I'm guessing that "gexperiments" means "googleexperiments" , and its probably something google uses to track everyone's time or something like that. so its probably nothing.

Taking screenshot using javascript in chrome packaged app

I need to grab the current html inside a chrome packaged app. I am aware of Taking screenshot using javascript for chrome extensions but when I tried this, chrome states that the "tab" permission is not allowed for packaged apps.
Is there any way I can reliably grab the current page?
You cannot do what you are trying to do with a packaged Chrome application. Instead, you should probably look at making an extension, as that would be the way to go if you want to interact with the current page.
If you're unsure, here's a resource for figuring exactly what you should choose: https://developer.chrome.com/webstore/choosing
Not from a chrome extension, as those are browser-centric solutions (not webpage-centric).
Niklas Von Hurtzen has created a very useful js extension called html2canvas that essentially does what you're looking for, just not as a chrome extension. You can see it here.
Once "rendered," the plugin will create a canvas element by traversing the DOM tree of whatever you hand to the extension. From there it's pretty simple... yourRenderedCanvasElement.toDataUrl() will return a data: URL representation of that canvas element, which by default is a PNG, giving you a "screenshot."
Edit: Ha, I see now that you reference this exact thing in the message thread in the other answer...

Using chrome.tabs.captureVisibleTab() from DevTools console

I'm curious as to whether it is possible to take a screenshot directly from Chrome's DevTools using chrome.tabs.captureVisibleTab (be it from the console or from within a snippet), without going through the process of creating an extension.
Is this somehow possible? If not, how would you suggest going about taking a screenshot that reliably mimics the current page (html2canvas doesn't seem to render everything properly). Thanks for your help.
Here is a page screenshot tool provided by Google. After installed, you may open "chrome-extension://cpngackimfmofbokmjmljamhdncknpmg/js/page_context.js" in browser to see its code. This extension do not use Chrome Extension API. It works well in most pages, except some complicated pages.

Opening Outlook by JavaScript in Firefox

I want to open Outlook from Javascript, it's for an internal application, nothing that will ever hit the web. The customer is using IE and Firefox and Outlook will be installed, security is not an issue.
"mailto:" just isn't sufficient in this case, since the requirement is that I need to attach a file to the mail, it seems that this cannot be done by using "mailto:" (found some old-ish forum entries, but nothing of what I tried worked and it seems that the mailto URL scheme doesn't officially support it).
But, in IE I can use ActiveX:
var outlookApp = new ActiveXObject("Outlook.Application");
and then I can mess around with it, add a body, add attachments and so on, perfect.
Is something like this possible in any way in Firefox?
What I already knew was that tiddlywiki does some extraordinary things, in that it can save itself somehow on the harddisk. So I looked at the source and found this:
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
Which, as I understand gives the Script access to the Browser API/XPConnect/XPCOM. But now I'm stuck. How would I actually open an Outlook object? Would this even be a working approach? I'm not sure. Maybe any other ideas? Any advice would be appreciated.
Update:
ok, after some reading I think I can answer one of my questions with: No, this approach won't work, since the Mozilla API that's implementing XPCOM doesn't support anything like opening an external program.
Still leaves the question: Any other ideas?
Answering my own question with this: Ignore the spec, it's a bad idea.
It could be solved with an ActiveX Plugin in Firefox, but actually it's far better to just not do something like that because of security issues, even if it is only an internal application. Some browser settings need to be changed to get something like that to work, which is risky. And finally, the spec contained a not-use-case here: "upon click of a button, open outlook to send an attached file via email". The stupid thing is, that there's actually nobody whom the employees would be allowed to send the file to, apart from other employees which can access the file in the internal network, so it's far easier (and can also be securily implemented) to just send a link to the file.

Categories

Resources