Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions js/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ require('macHandoff.js').initialize()
// default searchbar plugins

require('searchbar/placesPlugin.js').initialize()
require('searchbar/domainGuessPlugin.js').initialize()
require('searchbar/instantAnswerPlugin.js').initialize()
require('searchbar/bangsPlugin.js').initialize()
require('searchbar/customBangs.js').initialize()
Expand Down
38 changes: 38 additions & 0 deletions js/searchbar/domainGuessPlugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
var searchbarPlugins = require('searchbar/searchbarPlugins.js')

var urlParser = require('util/urlParser.js')

function showDomainGuess (text) {
searchbarPlugins.reset('domainGuess')

if (!text || text.indexOf(' ') !== -1 || text.indexOf('!') === 0 || urlParser.isPossibleURL(text)) {
return
}

var url

if (urlParser.isHTTPSUpgreadable(text)) {
url = 'https://' + text
} else {
url = 'http://' + text
}

searchbarPlugins.addResult('domainGuess', {
icon: 'carbon:earth-filled',
title: text,
secondaryText: l('visitSite'),
url: url
}, { allowDuplicates: true })
}

function initialize () {
searchbarPlugins.register('domainGuess', {
index: 3,
trigger: function (text) {
return !!text
},
showResults: showDomainGuess
})
}

module.exports = { initialize }
1 change: 1 addition & 0 deletions localization/languages/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"pasteAndGo": "Paste and Go", //context menu item
"DDGAnswerSubtitle": "Answer", //this is a noun - it is used as a subtitle when displaying Instant Answers from DuckDuckGo in the searchbar
"suggestedSite": "Suggested site", //this is used to label suggested websites from the DuckDuckGo API,
"visitSite": "Visit site",
"resultsFromDDG": "Results from DuckDuckGo", //this is used as a label to indicate which results come from DuckDuckGo's API
"taskN": "Task %n", //this is used as a way to identify which tab a task is in "task 1", "task 2", ...
/* custom commands
Expand Down