List of Promise API in manifest v3 - chrome-extension-manifest-v3

Overview of Manifest V3 states:
Promise support has been added to many methods, though callbacks are still supported as an alternative. (We will eventually support promises on all appropriate methods.)
Is there a list of APIs that has been converted to Promise?
For example, the following runs into error:
chrome.contextMenus.removeAll()
.then(() => console.log('done'));
// Uncaught TypeError: Cannot read properties of undefined (reading 'then')

I'm not aware of such a list but the support status for a given method will be shown in an IDE (via a tooltip or a method preview or a "Go to definition" command) if you install the official chrome-types package. Don't confuse it with #types/chrome by DefinitelyTyped offered in many IDE by default. The important difference is that the official package is autogenerated from the source code of Chromium, so it should reflect reality, although theoretically their crawler may have bugs.
To see which version of Chrome added the support there's no convenient method yet, so you'll have to check the source code directly and use the Blame feature inside.
Example 1, chrome.contextMenus.removeAll. Search for the method name removeAll using an expression like \bremoveAll\b file:extension.*(json|idl)$ (\b means boundary like a space or a doublequote), you'll see a file named "context_menus", click it, and look at the definition. Only callback is there, no async or Promise, which means it's not converted yet.
Example 2, chrome.tabs.sendMessage. The definition says returns_async, i.e. it supports Promise.
Click the Blame button in the top right corner.
When the panel loads, hover the title of a block inside that corresponds to returns_async line.
You'll see a bubble with the latest change, at this moment it's "Add promise support to SendMessage native hooks", which luckily describes the thing we look for. Otherwise you would have to dig further by clicking "View blame prior to this change".
Right-click the link "Commit xxxxxxx", and copy it, then paste in the addressbar and replace everything except the last long id with chromiumdash.appspot.com/commit/ so in our example it'll be
chromiumdash.appspot.com/commit/2cfa204a0da496b42c3a148d014df4aef45c43fc
The linked page says it's Chrome 99, so it'd be reasonable to add "minimum_chrome_version": "99" in manifest.json to ensure that users of older browsers won't install the extension and won't receive it in an automatic update. In case you really want to support users of older browsers you'll have to use this method in callback mode or apply your own promisifier.

Related

Detecting Quick Access command state

We have an application that is using Windows Ribbon Framework for an UI. The app itself is written in Delphi and uses Windows Ribbon Framework for Delphi to interface with the ribbon API.
Our ribbon XML places few commands into the Quick Access toolbar. Use can then remove/add commands either by using the built-in ribbon mechanism (selecting the drop/down button and clicking on a command name) or by selecting More commands command which opens the configuration dialog.
The problem I've encountered is that I cannot find a way to get the current state of commands in the QA collection (whether they are visible or not).
In the example above (picture) I would like to detect that first five commands are checked and that the last is not so I can prepare the configuration dialog accordingly.
I have no problems enumerating the IUICollection and accessing the items stored inside. I can also get the UI_PKEY_CommandId for each item. I cannot, however, find a way to read the checked/unchecked state. I tried reading UI_PKEY_BooleanValue and UI_PKEY_Enabled for all items in the collection, but they do not return that state.
I have also tried to monitor IUICommandHandler.UpdateProperty but it doesn't get called when such item is checked/unchecked (except that it is called with the UI_PKEY_Label key).
Does ribbon API even support this functionality?

Migrating to Vim from RubyMine - Interpreted Auto completion

Up until last week, I had been using RubyMine for my Rails development. I know it has a vim plugin but I have been working on migrating my development to vim and tmux. I don't want to keep using the mouse and VIM gives me a lot more flexibility. I have found plugins and workarounds for almost all the features I care about except the "interpreted auto complete" functionality in my first screenshot below. RubyMine interprets the whole rails application and offers sorted-by-relevance suggestions (as you can see, it's showing me instance variables and methods for the class in question and the modules it includes) THEN it shows (less relevant) methods available on the Object class. It also shows the method signature when there's one.
Also, in my second screenshot, you can see how RubyMine offers autocompletion for core Ruby classes.
Compare this to the bottommost screenshot. I do have completion but there's no way to find what I'm looking for. I'm using ctags , YouCompleteMe, vim-rails, vim-ruby and I also tried installing eclim to see if it makes a difference.
Is there a plugin I've missed that can enhance my auto completion? It doesn't look like RubyMine is doing something super crazy. pry can give me the same 'power' if it were running in the same 'context'.
First Screenshot (RubyMine interpreted auto complete):
Second Screenshot (RubyMine core Ruby classes auto complete):
Third Screenshot (vim omnifunc + ctags):
Important Note
This solution only works for Ruby 1.9+
I forked 'vim-ruby' at https://github.com/zxiest/vim-ruby and modified it as such:
Method signatures now appear in completion.
I disabled sorting by name for methods.
Plugins and Settings
vim-rails
I'm using vim-rails https://github.com/tpope/vim-rails
supertab
I'm using supertab https://github.com/ervandew/supertab instead of YouCompleteMe (mentioned in my question) although YouCompleteMe is super fast and automatic but there are currently some compatibility issues between my it and my vim-ruby fork.
vim-easytags
I'm using vim-easytags https://github.com/xolox/vim-easytags
Add this to your ~/.vimrc
:set tags=./tags;
:let g:easytags_dynamic_files = 1
Make sure to touch ./tags in your project directory.
Issue :UpdateTags -R **/*.* from vim in order for easytags to generate your tags file.
Remap omnicomplete
In order for omnicomplete to pop up, by default, we have to hit <C-X><C-O>. I remapped this to <C-Space> by inserting the following in my ~/.vimrc:
inoremap <C-#> <C-x><C-o>
I now press tab when I want supertab to complete my code and Ctrl+Space when I want omnicomplete to trigger and show method signatures for me. There's definitely a better way to integrate this (i.e. getting supertab to call omnicomplete after a dot)
And here goes the screenshot! Notice that method sorting being off allowed my custom resize method to appear on top and the signatures now appear in the completion (as well as in the editor when enter is pressed!)

jQuery mobile.changePage returns to first page after initial changePage

Here's a problem only with web browsers on the computer, in other words it's not a problem on smart phones as an app.
I updated my jquery mobile framework to the latest release, and i'm trying to log into my account which loads other pages, but as soon as it loads the other pages it loads back to the log in screen. My question is, are there any background functions tied to the changePage function that have changed since 1.0b2'ish release which may affect this?
There have been several changes made to the $.mobile.changePage() function including some deprecations that had code removed for the 1.0 release (latest at the time of this writing).
If you go here: http://jquerymobile.com/blog/, and search for "changePage", you will find some interesting information like this:
Removed support for the alpha signature of $.mobile.changePage() in
preparation for 1.0. Folks now how to use the signature that requires
the toPage (url or element) as the first arg, and options object as
the 2nd. See the events API documentation and commit log for more
info.
You could also take a look at the documentation for $.mobile.changePage() and make sure the current documentation fits with how you are currently using the function: http://jquerymobile.com/demos/1.0/docs/api/methods.html
Updated doc link for 1.1.0: http://jquerymobile.com/demos/1.1.0/docs/api/methods.html

Why is WSCript object not known to my script that's controlled by a custom IScriptControl?

I am using someone else's library that provides its own scripting host instance, it appears.
This lib provides me with functions to define the type of scripting language such as "jscript" and "vbscript", and I can supply it with script code and have that executed, with passing arguments in and back. So, basically, it works.
However, when I try to access the "WScript" object, I get an exception saying that this keyword is undefined.
The developer, not knowing much about this either (he only made this lib for me because I do not want to deal with Windows SDKs right now), told me that he is using "IScriptControl" for this.
Oh, and the lib also provides flags to allow "only safe subset" and "allow UI", which I set to false and true, respectively.
Does that ring a bell with anyone? Do a user of IScriptControl have to take extra steps in order to make a WScript object available? Or, can he use IScriptControl in a way that this is supplied automatically, just as when running the same script from wscript.exe?
Basically, all I need is the WScript.CreateObject function in order to access another app's API via COM.
I don't know why WScript is not known, but I suspect it is because the script host doesn't provide it. Maybe only wscript.exe does this.
If you are using Javascript, to create an object you can use new ActiveXObject(). If you are using VBScript, you can just use CreateObject.
See this article for some background.

Firefox extension: Embed javascript in a webpage

I want to insert some script into every page, which have some functions that will be called by the modified HTML of that page, using a Firefox extension. I am able to insert the JavaScript into the head of the HTML, and also modify the page, but the java script functions are not called by the onmouseover event.
Does someone has any pointer on how to do that, using java script in local extension or as a online resource.
No GreaseMonkey, I need to do it with my plugin and not ask user to install greasemonkey, my plugin and the scripts.
Greasemonkey does this. It's excellent!
Make a Greasemonkey script. See Userscripts.org for lots of example ones to work off.
Why not use Greasemonkey? It allows you to execute javascript on any page on Firefox, and if executing the code you enter isn't good enough you could dynamically add links to the head, too.
you can modify the DOM using Firebug. I am not sure if you can load files locally.. sounds malicious. Also, you can just run arbitrary javascript commands in the Firebug console (a la python/ruby console)
There are some Greasemonkey-to-extension "compilers" (or extension-wrappers) out there:
Arantius's GM compiler
Gina Trapani's multiple-GM-script compiler
I've used the first one with extensive internal tweaking over time. However, I don't believe the compiler is actively maintained (default max-version is only 3.0), so may not be up-to-date with the latest GreaseMonkey, or FireFox.
I think Gina Trapani's is more designed for multiple scripts targetting the same domain, but I haven't used it.
Neither of these is a "GreaseMonkey solution" per se, as the end-user never has to install GreaseMonkey. They get a real-live FireFox extension. The core is very similar to GM, but you can change or add as much as you like.

Resources