Chromeless window in Chrome extension? - javascript

So recently I've come across a Webapp on Chrome Web Store called Type Fu. What amazed me is they actually created a true chromeless window.
I'm thinking if I can do it in a Chrome extension because in most parts they use the same APIs. However, I can't find anything that will let me to do this effect.
chrome.tabs.create is not useful at all.
It would be madness if I can't do that in an extension because in my opinion, an extension should have more "power" than a webapp (a webpage basically).
I couldn't press Ctrl + Shift + I or even right-click on it. It's just like a real native program on my computer.
Some buttons will open another floating chromeless window.

...in most parts they use the same APIs
Chrome extensions are designed to interact with the browser. Chrome packaged apps are designed to be standalone and operate independently from the browser. Their APIs have now widely diverged. Just take a look at the API listings for apps and the equivalent listing for extensions, and you'll see that they are quite different.
In this case, the Type Fu uses the chrome.app.window API, particularly the frame: 'none' option of the create function.
As the name of app.window suggests, it's only available to packages apps, not extensions. The extension-based chrome.windows.create method will eventually support a type: 'panel' option that will supply visually similar functionality (see it at work in Google's Hangouts extension). It's described in the API with a note:
The 'panel' and 'detached_panel' types create a popup unless the '--enable-panels' flag is set.
Currently only Hangouts is whitelisted to use panels, but the discussion at Having panel behavior in chrome extension suggests that your extension can pretend to be Hangouts by adding a specific key value to your manifest:
"key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDsDApubb73tPfYlNIFxDu3K3/EHgV6/YOJXJkld1OZ20jW/cOht1j0NggnXhQYuu1mXFUufud4I2N7b5ydyg09gcM9Va3Zk17RhNV9smbPHOd4XlzJeXifX/9MgHPu4FzCen3CiSXsOeAELJIXEuT28xICriuUko/rNPwGeIB9VwIDAQAB"
However, I wouldn't rely on this undocumented behavior; Google is likely to fix it, or it may break something else in the future.
Until panels are fully supported then, you can begin developing your extension with the --enable-panel browser flag and hope the feature is enabled by default once you have completed development.

Related

Can firefox's multi-account containers extension be replicated in chrome or chromium based browsers?

I love the firefox extension multi-account containers. I want to switch to brave browser but I can't find a good alternative. Is it a functionality that can only work in firefox due to API limitations or is it possible to implement it in chromium based browsers via an extension?
If I want to create this extension can I make it exactly the same as firefox's multi-account containers? I tried to load the extension into brave but it has many errors due to the differences in the APIs I think. So the only way to do this would be to program it for chromium. Is that possible?
I found this reddit thread https://www.reddit.com/r/brave_browser/comments/kw2cff/brave_alternative_to_firefoxs_multiaccount/ it appears to suggest that containers are firefox exclusive and sessionbox is an alternative suggested. I tried sessionbox though it appears to be limited to having to click on the extension and then select a session to start the website in while multi-account containers can do that automatically if you set it to always open in container.
Are there extension API features that such an extension makes use of and chromium based browsers don't have?
Maybe this feature can be implemented not through an extension but directly through the browser, as brave is open source it should be possible for me to add this feature or fork it and add it there.
[this question is a duplicate of another question I asked; an attempt to make it more clear; I removed the other question]
Multi-account containers functionality requires Contextual identities browser extension API and which is only supported in FireFox.
As for 2023, it's not possible to implement FF's multi-containers in Brave/Chrome.
But you can spread the word and vote for this feature here:
https://community.brave.com/t/equivalent-of-multi-account-containers-or-temporary-containers-extension-ff/135573
It's not a lost cause but this feature has been discussed by Brave's team since their launch, about 5 years ago:
https://github.com/brave/brave-browser/issues/34
Their conclusion is that is too much work. They say this feature has to be implemented by Chrome first, otherwise they have to patch too many things.
The problem is that Google won't ever implement something like that in Chrome, IMO. The whole idea goes against their core business: track users for targeted advertisement.
There are some plugins you can give a try, but they are not practical (in my opinion). Also, I wouldn't trust a plugin to access all my browser data (history, cookies, etc).

Creating & Management of Electron-like Windows from Chrome Extension

Good day everyone!
I develop a Google Chrome Extension. The architecture is mainly built on using content script in Chrome tab and separate master window for providing basic management and user-oriented information. Extension should provide a good-user-experience and for that I have an appropriate list of criteria:
Creating master window in specified width & height, top & left. In some cases creating modal window.
Draw attention or focus to the master window for interacting with user.
Unresizable.
Zoomable by mouse wheel or buttons.
Toggle Always-on-Top.
Additional criteria. Extension should work properly out of box. Any tricky additional settings aren't satisfying for end users. Extension should work properly in Chromium-like browsers.
The current state of my Extension is that I use the Chrome Extension API's chrome.windows for creating (1) and focusing (2) to the master window, and chrome.tabs for zoom operations (4).
I know there is a limitation of using unresizable Chrome windows (3). Looks like it's a dead end.
My implementation of Always-on-Top feature (5) documented in chrome.windows is not working. Here's code I use:
chrome.windows.getCurrent({ windowTypes: ['panel'] }, function(window) {
chrome.windows.update(window.id, { focused: true }, function(w) {
w.alwaysOnTop = true;
});
});
The console.log says that w.alwaysOnTop is toggled from false to true, but there's no changes, and next call do the same. The accepted answer here Chrome extension pop up windows always on top says about Chrome flags, etc, which is not suitable for end users.
I have some information about chrome.app.window, it provides good features. But it seems that the developers will remove support for Chrome Apps. In this article Transitioning from Chrome Apps is highly recommend to use chrome.windows instead, but again not a word about support for (3) and (5).
Using the Window.open() don't make any effect in Chrome Dev 82.0.4056.3. It just do the same as Chrome.windows do. And something tells me that this is not quite a cross-browser solution.
On my opinion, the Electron BrowserWindow can do the best with above list of criteria. I know for that Electron combines Chromium and Node.js. But I can't find any more detailed documentation or appropriate examples about this topic.
Also last days I look a bit quickly on React and Angular opportunities. Seems like Angular is more suitable for Google. I'm total new to that frameworks.
So, here I am. Any help or clues on this topic will be very helpful for my purpose. Thanks in advance!

Add context menu in bookmark menu

I am trying to add a context menu item in the bookmark menu of Firefox (with a WebExtension). I read the contextMenus.create() article and the example works for me.
There are a bunch of context types, but none seems to work in the bookmark menu. Is this not possible?
What you desire is not currently possible in a WebExtension. In general, if there is capability that you desire in WebExtensions which does not already exist, you can:
File a Request For Enhancement (a bug) requesting the functionality. In the case of adding an item to the bookmark context menu, such a bug already exists: Bug 1370499: Consider support for bookmark context menus. The general direction from this tracking bug is that adding an entry to the bookmark context menu will be implemented at some point in time.
Create a WebExtension experiment: You can create a WebExtension experiment to implement the functionality. If you create a WebExtension experiment, you can request that it be integrated into Firefox (which may, or may not happen). Having a WebExtension experiment will make it more likely that something along the lines of what you want is implemented, because it reduces the amount of Mozilla developer time required to do so. As WebExtension Experiments are actually legacy add-ons, they will not be able to function in Firefox as of the Release version of Firefox 57 (2017-11-14).
WebExtension experiments support (and legacy add-ons in general) is disabled by default in Firefox Nightly. However, in Nightly, you can enable an about:config preference, extensions.legacy.enabled, which allows you to use legacy extensions, including WebExtension Experiments. This is expected to be also be true in Developer Edition, but has not been verified. WebExtension Experiments and legacy add-ons certainly won't function in the Release version of Firefox 57.
One thing that might improve the chance of having some functionality added to Firefox is to look through what is possible in Chrome extensions. If there is a Chrome extension API which closely matches what you desire, then it's more likely that Mozilla will implement it.
Unfortunately, there is a huge amount of functionality available in the other types of extensions which is not possible in WebExtensions (at least currently, and almost all of it permanently), but it's possible that any specific functionality could implemented. Some things not initially supported have been implemented, at least to a limited extent (e.g. Sidebars).

browser plug-in or extension, which to choose?

I intend to modify the display of existing websites.
For example, when Google returns search results, can I customize the web page displaying (such as adding some bubble visualizations onto that page's blank places) ? Could it be done using browser plug-in or extension?
Based on my knowledge, a browser extension, such as firefox or chrome extension, is usually for adding tiny icons to the address bar.
Could it be done using browser plug-in or extension?
Yes. But you don't want to write a browser plug-in. They're fairly complicated to write and users are reticent to install them (with good reason) Further, you'd have to write two, as Mozilla and Google can't agree on a format (Chrome is removing the venerable NPAPI, but Mozilla won't implement Google's PPAPI, claiming that it's a moving target with inadequate documentation).
Based on my knowledge, a browser extension, such as firefox or chrome extension, is usually for adding tiny icons to the address bar.
No. Firefox add-ins and Chrome extensions can do a lot more than that, including modifying the page once it's rendered.
So you'll probably want to write a Firefox add-in and a Chrome extension. (Sadly, yes, that's two codebases to maintain, although they use similar technologies — HTML, CSS, JavaScript — so you can share a bit between them.)

Ctrl + C / Ctrl + V in Google Sheets - how does it work? [duplicate]

There are multiple similar questions in stackoverflow which deal with how to Cut, Copy, and Paste from JavaScript (in response to a button press, for instance) without the user having to use CTRL+X, C, or V.
All these answers suggest either that you are insane for wanting to do this and that users should never have their clipboards violated in such a profane manner, or to use the hack of an invisible Flash movie (which has questionable support).
However, Google Docs does this, and does not use a Flash movie. You can open a Google Document, Go to the Edit menu, choose "Paste" (or Cut or Copy) and NOT get a browser window that tells you "Your browser security settings don't permit the editor to automatically execute copying operations."
However, go to another rich text editor (CKEditor or TinyMCE for instance, but this is common among them all) and try that same command. You will get a message that reads:
"Your browser security settings don't permit the editor to automatically execute copying operations."
So the question is simply: What is Google Docs doing to allow users to Cut, Copy, and Paste via a menu button that doesn't run in to security issues?
A quick look at all my browsers show that I have a Google Docs extension installed. I know for a fact it is possible to do with the use of an extension (Browser extensions play in a different, more "trusted" sandbox), which you could (and people do) use these to expose an API to javascript used within their sites within the browser in which the extension is installed.
Based on the fact that I definitely have extensions from google to allow "for the viewing and editing of google docs" across all my browsers - this is how they do it. Building extensions for browsers is a per-browser project and the code you write for an extension in one browser is typically only partially portable.
Google does it because its user base intrinsically trust it and so they happily download and install the necessary extensions and plugins Google publishes for varying web-based services that extend beyond the capacity of standard web technologies. We trust that Google won't get our stuff pwned.
So the short answer is: You can't do it. Unless you're prepared to write the necessary extensions/plugins for Chrome, Firefox, Safari, IE8+... etc... Google works because of an extension called Google Docs installed within your browser. (IE, in Google Chrome navigate to chrome://extensions/ to see your own google docs extension).
If you want to give extension writing a try for Chrome, visit their guide on how to do so! Be forewarned however, that installing extensions takes significant trust on a user's part and should not be required early in any "sales funnel."
Edits: Because I'm horrible at grammatically correct English

Categories

Resources