Conditionally enable contextMenus based on Tab URL - firefox-addon-webextensions

contextMenus has a enabled property which can be set to true or false.
contextMenus.update() can be used to update the properties.
I would like to enable or disable a contextmenu (one of a few contextmenus) based on conditions.
contextMenus.onClicked.addListener() is fired after the contextmenu is shown so there is no point to use update to change the enabled property (based on tab URL).
Is there a way to change the enabled property before it is shown? (like popupshowing event was in Firefox)
Update:
Note: At this point I am looking for any method of controlling the contextmenu (based on Tab URL) BEFORE it is displayed. The case listed here is just one
example of a situation where such method would be needed.
I am looking for a direct method and not a hack by listening to all mouse events. Furthermore, using a series of asynchronous functions will have unpredictable results.
The actual contexts in this case is tab (which is only supported by Firefox 53.*+).
I am not aware of any mouse event listener for it for this purpose.
Injecting scripts into the context is the heart of the problem.
Firefox (& Chrome) by design prevent script injection into certain locations eg: addons.mozilla.org, about:* or Chrome Web Store; etc.
The problem is more pronounced on Firefox due to unavailability of a number of APIs.
(You can read my comments: WebExtension content script not working on mozilla.org sites)
At the moment, I am forced to run a series of functions to check if the page is blocked or not, after action has been initiated from the contextmenu.
I was looking for a way to disable some of the extensions contextmenu items based on the URL of the tab. In other words, disable few of the extension's contextmenu items on addons.mozilla.org
There are some tab listeners but they don't seem to suit the purpose ie (tabs.onCreated: Fired when a tab is created. Note that the tab's URL may not be set at the time this event fired.)
PS. While I am working on a Firefox extension, since Firefox & Chrome share the similar API and the enable property is used by both, the question has been tagged with both browsers. I have re-ordered the tags to list Firefox as its primary target.
PS2. Stack Overflow puts it under Chrome Extension regardless, so I have removed the Chrome reference tag.
PS3. Voting to close a question prematurely and without knowing all the facts is rather counterproductive.

Related

How to make an HTML page to be shown when Pepper boots

I have a behavior which purpose is to show an HTML page (hosted on the robot). I want that behavior to be loaded on boot and that HTML page to be shown on the Pepper's tablet when Pepper is booted.
I have added it to the robot default behaviors but that doesn't do the trick. It shows me that this behavior is running, that it is in the default behaviors but the HTML page is not shown. Just to make it clear when this behavior is not running and I trigger it, it works as it is intended - I mean the problem is not in the HTML code.
It might be that your behavior is started before the AutonomousLife service or before ALTabletService is ready. This is possible with default behaviors. In your code you need to wait for those 2 to be ready otherwise:
if ALTabletService is not ready, your code will just do nothing
if ALAutonomousLife starts after your app, it will reset the tablet so your page will be hidden.
The best solution is probably to not add it as a default behavior, but edit the app properties and set this behavior as a "solitary" activity, and use a "launch trigger condition" that is always true, like "1".
In that case, as soon as Pepper doesn't have any interactive behavior to start, it will run yours (so it will display the webpage). Also with this solution you ensure that all other services are ready before your behavior is started.
More info in the documentation about how to create solitary activites and launch trigger conditions.

Talk back announce Double Tap to Activate on header element

I am working on a mobile site which needs to be accessible with screen reader. I am testing it with Talk back on android device. Problem is Talk back announce "Double Tap to Activate" on each element, even if it is Header (H1, H2...) or a text only like Span. I am not sure how to disable it.
But it should read "Double Tap to Activate" on button, select, link etc actionable item.
Can it be done by Talk back setting?
Thanks.
I just heard from a knowledgeable accessibility expert, "Apparently, Android thinks anything that has a tabindex of 0 or -1 is automatically an interactive element and will announce the "double-tap to activate" hint."
So possibly you could set your tabindexes to something else and see if that fixes it?
I found the issue exists in jQuery mobile plugin. I am using jQuery.mobile-1.3.1.js plugin in my application which binds "vclick" event on document. And which causes double tap issue. To resolve this, I unbind "vclick" event on document.ready method on master page.
There is one more plugin which can be a reason of this issue i.e. jQuery.validate.js. I found it binds "click" event on , and screen reader (Talk back in my case) takes non-clickable elements as non-clickable. So same unbind is useful for "click" event also. Hope this information would help to some one.
This is now fixed on Android Chrome Canary
https://bugs.chromium.org/p/chromium/issues/detail?id=1023229

Angular and Google tag manager (GTM) gtm.click

I am running into a problem, and I cannot seem to find a fix for it. The situation is as follows the marketing department wants to integrate GTM. Which is fine as they want to have full control over the different third party providers they wish to integrate. But for this to happen they would like to have the ability to track all clicks on a page.
And they came back to me that currently no click events are being tracked with the current configuration within GTM. At first the thought was that events were not propagating (bubbling) upwards. But having tested this myself by binding a event listener to the document (click) (see below) all div, buttons etc. with an ng-click directives did reach this handler without problems.
document.addEventListener("click", function(event){
console.dir(event.target);
});
So my assumption was that there was something wrong with the configuration but after looking at the configuration (one I created myself which looks as follows):
I still could not get it to work. Buttons that already use angulartics - https://luisfarzati.github.io/angulartics/ to send an event to the GTM container work as expected:
Download
Only the catch all click events (or any filter on it like purely looking at button clicks) does not. Now after looking at it a little more it seems GTM expects the gtm.click _event to happen. But I can't figure out (gazing through the gtm.js file) how they bind to all click events within the document (there is a click binding on the document after initialization but I am unsure if this is GTM or something from angular). And even if so I have placed many breakpoints within this file which seemingly could be related to it but none of them triggered when something was clicked.
So my question is, has anybody got experience combining angularjs with angulartics and GTM while having it catch all click/touch/mousedown etc. events and send these to GTM?
Make sure that you pusblished GTM container after you made some changes. Use "Publish Now" or "Preview and Debug" buttons inside of GTM interface(top-right corner).
Because according to your tag config this tag should fire every time when user clicks something on the website.
Regarding to "gtm.click" - this GTM-event will fire every time, when user clicks something on the website.
On the screenshot you may see, how it looks like in GTM debug mode("Preview and Debug") when user clicking on somethig at web-page, when GTM click listener turned on(like in your tag).
May be some relevant articles from my website about tracking of buttons/links on GTM will help you too:
http://konygin.net/gtm/tracking-links-en/
http://konygin.net/gtm/tracking-buttons-en/
My problem turned out to be that the person (from marketing) who gave me the html GTM tags (noscript / script) did not copy it properly (or something went wrong when it was pasted within JIRA). And after I copied it directly (having gotten access to the GTM admin panel) it worked as I would expect it to work.
Seeing as I debugged it by trying to only have one index.html with purely a button in it. Even at that point the tracker did not work and I became suspicious why that was happening as there was no angular code any more that could cause the problems.
Lesson learned, next time copy code yourself when you need it to make sure it does not get corrupted along the way :/

How to keep scroll position on Angular Application on FIrefox

I've been struggling with this problem for a long time and coudn't find an answer. My Application contains a dynamic-sized feed that can be re-accessed via history.back for example, and in this case It is interesting to ba back on the same scroll position where I left. Seems like Chrome and few other browsers do it automatic, but on Firefox it doesn't.
I could go around this problem by setting a small timeout and finding the scroll position that was saved before, but I would like to know why is it not working straight like on other browsers. Using AngularScroll is not an option, and as I read it is activated by default, otherwise chrome would not be able to scroll automatic.
Setting a static height on the container fixes the problem, but I need to catch it via a directive when the scope is done and add this attribute, which doesnt work as well.

WP7 WebBrowserTask without url entry textbox

This might not be possible but I thought I'd check with everyone.
Is it possible to load a WebBrowserTask on WP7 but to have the url entry box collapsed? I'd also like to set IsHitVisble to false?
The reason I want to do this is to load a url (through databinding) but ensure that the user can't browse to other links on the page. I also need to keep the phones share control in the tool bar so I can't just use a webbrowser control and set the source to the url.
Does anyone have any ideas?
Not possible. You can use a WebBrowserControl inside your own app, but it's not recommended.
Basically such odd/weird limitations as this, don't belong in any modern day craftsmanship. And thus why it isn't a possibility (thanks Microsoft!)

Resources