Skip to content

Commit e158169

Browse files
committed
(JS) update browserChromeBookmarkKeywords.uc.js
to handle keyword/input highlighting differently. (CSS) update stylesheet to account for the highlighting change. update the github stylesheet a bit.
1 parent f558924 commit e158169

File tree

3 files changed

+28
-16
lines changed

3 files changed

+28
-16
lines changed

JS/browserChromeBookmarkKeywords.uc.js

+20-15
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// ==UserScript==
22
// @name Browser Chrome Bookmark Keywords
3-
// @version 1.0
3+
// @version 1.0.1
44
// @author aminomancer
55
// @homepage https://github.com/aminomancer/uc.css.js
66
// @description Allow the creation of special keyword bookmarks with
@@ -255,6 +255,7 @@
255255
let title;
256256
let prefix;
257257
let icon;
258+
let inputHighlight;
258259

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

268269
if (prefix && searchString && (hadPlaceholder || !ucjs)) {
269-
// If we have a search string, the result has the title
270-
// "host: searchString".
271-
title = UrlbarUtils.strings.formatStringFromName("bookmarkKeywordSearch", [
272-
prefix,
273-
queryContext.tokens
274-
.slice(1)
275-
.map(t => t.value)
276-
.join(" "),
277-
]);
270+
let format = (val1, val2) =>
271+
UrlbarUtils.strings.formatStringFromName("bookmarkKeywordSearch", [val1, val2]);
272+
let typedValue = queryContext.tokens
273+
.slice(1)
274+
.map(t => t.value)
275+
.join(" ");
276+
title = format(prefix, typedValue);
277+
inputHighlight = { title: [[prefix.length + format("", "").length, typedValue.length]] };
278278
} else {
279279
title = ucjs && prefix ? prefix : UrlbarUtils.unEscapeURIForUI(url);
280280
}
281281

282-
let result = new UrlbarResult(
283-
UrlbarUtils.RESULT_TYPE.KEYWORD,
284-
UrlbarUtils.RESULT_SOURCE.BOOKMARKS,
282+
let [payload, highlights] = [
285283
...UrlbarResult.payloadAndSimpleHighlights(queryContext.tokens, {
286284
title: [title, UrlbarUtils.HIGHLIGHT.TYPED],
287285
url: [url, UrlbarUtils.HIGHLIGHT.TYPED],
288-
keyword: [keyword, UrlbarUtils.HIGHLIGHT.TYPED],
286+
keyword,
289287
input: queryContext.searchString,
290288
postData,
291289
icon,
292290
ucjs,
293-
})
291+
}),
292+
];
293+
294+
let result = new UrlbarResult(
295+
UrlbarUtils.RESULT_TYPE.KEYWORD,
296+
UrlbarUtils.RESULT_SOURCE.BOOKMARKS,
297+
payload,
298+
inputHighlight ?? highlights
294299
);
295300
result.heuristic = true;
296301
addCallback(this, result);

resources/in-content/site-github.css

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ which requires Stylus. don't use this stylesheet if you don't have that theme, i
1717
font-size: 14px !important;
1818
}
1919

20+
.previewable-comment-form textarea {
21+
min-height: 350px !important;
22+
}
23+
2024
tt, code, samp,
2125
.input-monospace {
2226
font-family: Fira Code UC, Fira Code, SF Mono, ui-monospace, SFMono-Regular, SF Mono, Menlo,

uc-urlbar-results.css

+4-1
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,7 @@ by underlining them (requires urlbarMods.uc.js) */
478478

479479
.urlbarView-row[has-action] .urlbarView-title strong,
480480
.urlbarView-row[has-action] .urlbarView-title[isurl],
481+
.urlbarView-row[type="bookmark"]:not([has-url]) .urlbarView-title,
481482
.urlbarView-row[has-url] .urlbarView-title,
482483
.urlbarView-row .urlbarView-tag,
483484
.urlbarView-row:where([type="tabtosearch"], [type="tokenaliasengine"]) .urlbarView-title,
@@ -497,6 +498,7 @@ by underlining them (requires urlbarMods.uc.js) */
497498
.urlbarView-row:where([type="tabtosearch"], [type="tokenaliasengine"])[selected] .urlbarView-title,
498499
.urlbarView-row[has-action][selected] .urlbarView-title strong,
499500
.urlbarView-row[has-action][selected] .urlbarView-title[isurl],
501+
.urlbarView-row[type="bookmark"][selected]:not([has-url]) .urlbarView-title,
500502
.urlbarView-row[has-url][selected] .urlbarView-title,
501503
.urlbarView-row[selected] .urlbarView-tag,
502504
.urlbarView-row[selected]:not([has-url])
@@ -512,6 +514,7 @@ by underlining them (requires urlbarMods.uc.js) */
512514
}
513515

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

654-
.urlbarView-row:where([type="tabtosearch"], [type="tokenaliasengine"]):not([selected], [show-action-text], :hover)
657+
.urlbarView-row:where([type="tabtosearch"], [type="tokenaliasengine"], [type="bookmark"]:not([has-url])):not([selected], [show-action-text], :hover)
655658
> .urlbarView-row-inner
656659
> .urlbarView-no-wrap
657660
> .urlbarView-action {

0 commit comments

Comments
 (0)