make uBO/webext functional on Firefox for Android Nightly

This commit is contained in:
gorhill 2017-07-24 19:25:49 -04:00
parent 21cafe7eb3
commit 906cb34716
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
3 changed files with 30 additions and 21 deletions

View File

@ -327,7 +327,9 @@ vAPI.tabs.registerListeners = function() {
};
var onActivated = function(details) {
vAPI.contextMenu.onMustUpdate(details.tabId);
if ( vAPI.contextMenu instanceof Object ) {
vAPI.contextMenu.onMustUpdate(details.tabId);
}
};
var onUpdated = function(tabId, changeInfo, tab) {
@ -628,7 +630,7 @@ vAPI.setIcon = (function() {
tabId = toChromiumTabId(tabId);
if ( tabId === 0 ) { return; }
if ( chrome.browserAction.setIcon instanceof Object ) {
if ( chrome.browserAction.setIcon !== undefined ) {
chrome.browserAction.setIcon(
{
tabId: tabId,
@ -648,7 +650,7 @@ vAPI.setIcon = (function() {
}
}
);
} else if ( chrome.browserAction.setTitle instanceof Object ) {
} else if ( chrome.browserAction.setTitle !== undefined ) {
chrome.browserAction.setTitle({
tabId: tabId,
title: titleTemplate.replace(
@ -658,10 +660,19 @@ vAPI.setIcon = (function() {
});
}
vAPI.contextMenu.onMustUpdate(tabId);
if ( vAPI.contextMenu instanceof Object ) {
vAPI.contextMenu.onMustUpdate(tabId);
}
};
})();
chrome.browserAction.onClicked.addListener(function(tab) {
vAPI.tabs.open({
select: true,
url: 'popup.html?tabId=' + tab.id + '&mobile=1'
});
});
/******************************************************************************/
/******************************************************************************/

View File

@ -29,7 +29,7 @@
<em:targetApplication>
<Description>
<em:id>{{aa3c5121-dab2-40e2-81ca-7ea25febc110}}</em:id>
<em:minVersion>54.0</em:minVersion>
<em:minVersion>56.0</em:minVersion>
<em:maxVersion>*</em:maxVersion>
</Description>
</em:targetApplication>

View File

@ -27,12 +27,10 @@
/******************************************************************************/
var api = {
update: function() {}
};
if ( vAPI.contextMenu === undefined ) {
return api;
return {
update: function() {}
};
}
var µb = µBlock;
@ -142,20 +140,20 @@ vAPI.contextMenu.onMustUpdate = update;
/******************************************************************************/
api.update = function(tabId) {
if ( µb.userSettings.contextMenuEnabled && tabId === undefined ) {
vAPI.tabs.get(null, function(tab) {
if ( tab ) {
update(tab.id);
}
});
return;
return {
update: function(tabId) {
if ( µb.userSettings.contextMenuEnabled && tabId === undefined ) {
vAPI.tabs.get(null, function(tab) {
if ( tab ) {
update(tab.id);
}
});
return;
}
update(tabId);
}
update(tabId);
};
return api;
/******************************************************************************/
})();