Skip to content

Commit

Permalink
(JS) update browserChromeBookmarkKeywords.uc.js
Browse files Browse the repository at this point in the history
to handle keyword/input highlighting differently.
(CSS) update stylesheet to account for the highlighting change.
update the github stylesheet a bit.
  • Loading branch information
aminomancer committed Jun 19, 2022
1 parent f558924 commit e158169
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 16 deletions.
35 changes: 20 additions & 15 deletions JS/browserChromeBookmarkKeywords.uc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ==UserScript==
// @name Browser Chrome Bookmark Keywords
// @version 1.0
// @version 1.0.1
// @author aminomancer
// @homepage https://github.com/aminomancer/uc.css.js
// @description Allow the creation of special keyword bookmarks with
Expand Down Expand Up @@ -255,6 +255,7 @@
let title;
let prefix;
let icon;
let inputHighlight;

if (ucjs) {
let bm = await PlacesUtils.bookmarks.fetch({ url: uri });
Expand All @@ -266,31 +267,35 @@
}

if (prefix && searchString && (hadPlaceholder || !ucjs)) {
// If we have a search string, the result has the title
// "host: searchString".
title = UrlbarUtils.strings.formatStringFromName("bookmarkKeywordSearch", [
prefix,
queryContext.tokens
.slice(1)
.map(t => t.value)
.join(" "),
]);
let format = (val1, val2) =>
UrlbarUtils.strings.formatStringFromName("bookmarkKeywordSearch", [val1, val2]);
let typedValue = queryContext.tokens
.slice(1)
.map(t => t.value)
.join(" ");
title = format(prefix, typedValue);
inputHighlight = { title: [[prefix.length + format("", "").length, typedValue.length]] };
} else {
title = ucjs && prefix ? prefix : UrlbarUtils.unEscapeURIForUI(url);
}

let result = new UrlbarResult(
UrlbarUtils.RESULT_TYPE.KEYWORD,
UrlbarUtils.RESULT_SOURCE.BOOKMARKS,
let [payload, highlights] = [
...UrlbarResult.payloadAndSimpleHighlights(queryContext.tokens, {
title: [title, UrlbarUtils.HIGHLIGHT.TYPED],
url: [url, UrlbarUtils.HIGHLIGHT.TYPED],
keyword: [keyword, UrlbarUtils.HIGHLIGHT.TYPED],
keyword,
input: queryContext.searchString,
postData,
icon,
ucjs,
})
}),
];

let result = new UrlbarResult(
UrlbarUtils.RESULT_TYPE.KEYWORD,
UrlbarUtils.RESULT_SOURCE.BOOKMARKS,
payload,
inputHighlight ?? highlights
);
result.heuristic = true;
addCallback(this, result);
Expand Down
4 changes: 4 additions & 0 deletions resources/in-content/site-github.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ which requires Stylus. don't use this stylesheet if you don't have that theme, i
font-size: 14px !important;
}

.previewable-comment-form textarea {
min-height: 350px !important;
}

tt, code, samp,
.input-monospace {
font-family: Fira Code UC, Fira Code, SF Mono, ui-monospace, SFMono-Regular, SF Mono, Menlo,
Expand Down
5 changes: 4 additions & 1 deletion uc-urlbar-results.css
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,7 @@ by underlining them (requires urlbarMods.uc.js) */

.urlbarView-row[has-action] .urlbarView-title strong,
.urlbarView-row[has-action] .urlbarView-title[isurl],
.urlbarView-row[type="bookmark"]:not([has-url]) .urlbarView-title,
.urlbarView-row[has-url] .urlbarView-title,
.urlbarView-row .urlbarView-tag,
.urlbarView-row:where([type="tabtosearch"], [type="tokenaliasengine"]) .urlbarView-title,
Expand All @@ -497,6 +498,7 @@ by underlining them (requires urlbarMods.uc.js) */
.urlbarView-row:where([type="tabtosearch"], [type="tokenaliasengine"])[selected] .urlbarView-title,
.urlbarView-row[has-action][selected] .urlbarView-title strong,
.urlbarView-row[has-action][selected] .urlbarView-title[isurl],
.urlbarView-row[type="bookmark"][selected]:not([has-url]) .urlbarView-title,
.urlbarView-row[has-url][selected] .urlbarView-title,
.urlbarView-row[selected] .urlbarView-tag,
.urlbarView-row[selected]:not([has-url])
Expand All @@ -512,6 +514,7 @@ by underlining them (requires urlbarMods.uc.js) */
}

.urlbarView-row[has-action] .urlbarView-title[isurl] strong,
.urlbarView-row[type="bookmark"]:not([has-url]) .urlbarView-title strong,
.urlbarView-row[has-url] .urlbarView-title strong,
.urlbarView-row .urlbarView-tag strong {
font-weight: var(--urlbar-result-strong-font-weight, 500) !important;
Expand Down Expand Up @@ -651,7 +654,7 @@ by underlining them (requires urlbarMods.uc.js) */
padding-inline-start: 16px;
}

.urlbarView-row:where([type="tabtosearch"], [type="tokenaliasengine"]):not([selected], [show-action-text], :hover)
.urlbarView-row:where([type="tabtosearch"], [type="tokenaliasengine"], [type="bookmark"]:not([has-url])):not([selected], [show-action-text], :hover)
> .urlbarView-row-inner
> .urlbarView-no-wrap
> .urlbarView-action {
Expand Down

0 comments on commit e158169

Please sign in to comment.