desertpureolive
(desertpureolive@protonmail.com)
January 19, 2021, 10:04am
1
I tried omnibox with the following code from MDN . When I trying, I temporarily loaded manifest.json
from about:debugging
. This worked in a normal browser, and typing cs a
show a some suggestion.
However, this suggestion feature is not working in private mode. This did not change even if I allowed it to run in a private window. How can I get the omnibox suggestion feature to work in private mode?
Add:
I also tried check “Show search suggestions in Private Windows” option, but that didn’t change the results. I also found that execute the simple console.log
function in private mode didn’t work for the onInputChange
event.
Can you upload a test extension that demonstrates this behavior?
desertpureolive
(desertpureolive@protonmail.com)
January 19, 2021, 2:04pm
3
Thanks for reply. I’m using below source code. This temporary extension was ran in the following environment:
Windows 10
Firefox 84.0.2 (64 bit)
manifest.json
{
"manifest_version": 2,
"name": "Custom suggestion",
"version": "1.0",
"description": "Custom suggestion using omnibox.",
"background": {
"scripts": [
"background.js"
]
},
"omnibox": {
"keyword": "cs"
},
"permissions": [
"bookmarks",
"tabs"
]
}
background.js
// ref. https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/omnibox/onInputChanged#examples
browser.omnibox.setDefaultSuggestion({
description: "Type the name of a CSS property"
});
/*
Very short list of a few CSS properties.
*/
const props = [
"animation",
"background",
"border",
"box-shadow",
"color",
"display",
"flex",
"flex",
"float",
"font",
"grid",
"margin",
"opacity",
"overflow",
"padding",
"position",
"transform",
"transition"
];
const baseURL = "https://developer.mozilla.org/en-US/docs/Web/CSS/";
/*
Return an array of SuggestResult objects,
one for each CSS property that matches the user's input.
*/
function getMatchingProperties(input) {
var result = [];
for (prop of props) {
if (prop.indexOf(input) === 0) {
console.log(prop);
let suggestion = {
content: baseURL + prop,
description: prop
}
result.push(suggestion);
} else {
if (result.length != 0) {
return result;
}
}
}
return result;
}
browser.omnibox.onInputChanged.addListener((input, suggest) => {
suggest(getMatchingProperties(input));
});
browser.omnibox.onInputEntered.addListener((url, disposition) => {
switch (disposition) {
case "currentTab":
browser.tabs.update({url});
break;
case "newForegroundTab":
browser.tabs.create({url});
break;
case "newBackgroundTab":
browser.tabs.create({url, active: false});
break;
}
});
Thanks.
You can also zip the complete extension and attach it to your reply.
The Upload icon is the 7th from the left (arrow pointing up)
desertpureolive
(desertpureolive@protonmail.com)
January 20, 2021, 5:59am
5
I have attached a zip file that contains the minimal source code to reproduce my problem.
example.zip (1.1 kb)
gregp
(Gregory Pappas)
January 13, 2023, 10:18pm
6
This bug was fixed in Firefox 110 (bug 1779400 ).