Skip to content

Commit

Permalink
(JS) update some scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
aminomancer committed Jul 22, 2022
1 parent 1b09509 commit b0664f2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 42 deletions.
44 changes: 8 additions & 36 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.1.1
// @version 1.1.2
// @author aminomancer
// @homepage https://github.com/aminomancer/uc.css.js
// @description Allow the creation of special keyword bookmarks with
Expand Down Expand Up @@ -116,31 +116,12 @@
function init() {
const lazy = {};
XPCOMUtils.defineLazyModuleGetters(lazy, {
BrowserWindowTracker: "resource:///modules/BrowserWindowTracker.jsm",
L10nCache: "resource:///modules/UrlbarUtils.jsm",
ObjectUtils: "resource://gre/modules/ObjectUtils.jsm",
UrlbarUtils: "resource:///modules/UrlbarUtils.jsm",
UrlbarPrefs: "resource:///modules/UrlbarPrefs.jsm",
UrlbarProvidersManager: "resource:///modules/UrlbarProvidersManager.jsm",
UrlbarProviderTopSites: "resource:///modules/UrlbarProviderTopSites.jsm",
UrlbarSearchOneOffs: "resource:///modules/UrlbarSearchOneOffs.jsm",
UrlbarTokenizer: "resource:///modules/UrlbarTokenizer.jsm",
UrlbarUtils: "resource:///modules/UrlbarUtils.jsm",
BrowserSearchTelemetry: "resource:///modules/BrowserSearchTelemetry.jsm",
BrowserUIUtils: "resource:///modules/BrowserUIUtils.jsm",
CONTEXTUAL_SERVICES_PING_TYPES: "resource:///modules/PartnerLinkAttribution.jsm",
ExtensionSearchHandler: "resource://gre/modules/ExtensionSearchHandler.jsm",
PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.jsm",
PromiseUtils: "resource://gre/modules/PromiseUtils.jsm",
ReaderMode: "resource://gre/modules/ReaderMode.jsm",
PartnerLinkAttribution: "resource:///modules/PartnerLinkAttribution.jsm",
SearchUIUtils: "resource:///modules/SearchUIUtils.jsm",
SearchUtils: "resource://gre/modules/SearchUtils.jsm",
UrlbarController: "resource:///modules/UrlbarController.jsm",
UrlbarEventBufferer: "resource:///modules/UrlbarEventBufferer.jsm",
UrlbarQueryContext: "resource:///modules/UrlbarUtils.jsm",
UrlbarSearchUtils: "resource:///modules/UrlbarSearchUtils.jsm",
UrlbarValueFormatter: "resource:///modules/UrlbarValueFormatter.jsm",
UrlbarView: "resource:///modules/UrlbarView.jsm",
CONTEXTUAL_SERVICES_PING_TYPES: "resource:///modules/PartnerLinkAttribution.jsm",
});

const UrlbarProvidersManager = gURLBar.view.controller.manager;
Expand All @@ -151,12 +132,6 @@
schema.properties.ucjs = { type: "boolean" };

if (!gURLBar.pickResult.BCBK_modified) {
const { ExtensionSearchHandler } = ChromeUtils.import(
"resource://gre/modules/ExtensionSearchHandler.jsm"
);
const { PartnerLinkAttribution, CONTEXTUAL_SERVICES_PING_TYPES } = ChromeUtils.import(
"resource:///modules/PartnerLinkAttribution.jsm"
);
const SCALAR_CATEGORY_TOPSITES = "contextual.services.topsites.click";
eval(
`gURLBar.pickResult = function ` +
Expand Down Expand Up @@ -204,7 +179,7 @@
class BrowserChromeBookmarkKeywords extends UrlbarProvider {
/**
* Returns the name of this provider.
* @returns {string} the name of this provider.
* @returns {string} The name of this provider.
*/
get name() {
return "BookmarkKeywords";
Expand All @@ -220,7 +195,7 @@

/**
* Returns the type of this provider.
* @returns {integer} one of the types from UrlbarUtils.PROVIDER_TYPE.*
* @returns {integer} One of the types from UrlbarUtils.PROVIDER_TYPE.*
*/
get type() {
return UrlbarUtils.PROVIDER_TYPE.HEURISTIC;
Expand All @@ -230,7 +205,7 @@
* Whether this provider should be invoked for the given context.
* If this method returns false, the providers manager won't start a query
* with this provider, to save on resources.
* @param {UrlbarQueryContext} queryContext The query context object
* @param {UrlbarQueryContext} queryContext The query context object.
* @returns {boolean} Whether this provider should be invoked for the search.
*/
isActive(queryContext) {
Expand All @@ -256,7 +231,6 @@
* element parameter, this is pretty much useless because it's not always
* passed. If you really need to do something with the result element, I
* suggest using this: gURLBar.view._rows.children[result.rowIndex]
*
* @param {UrlbarResult} result The result that was picked.
* @param {Event} event The event that picked the result.
* @param {DOMElement} element The picked view element, if available.
Expand All @@ -273,9 +247,8 @@

/**
* Starts querying.
* @param {object} queryContext The query context object
* @param {function} addCallback Callback invoked by the provider to add a new
* result.
* @param {object} queryContext The query context object.
* @param {function} addCallback Callback invoked by the provider to add a new result.
*/
async startQuery(queryContext, addCallback) {
let keyword = queryContext.tokens[0]?.value;
Expand Down Expand Up @@ -343,7 +316,6 @@
* Returns a set of parameters if a keyword is registered and the search
* string can be bound to it. For browser chrome keyword bookmarks, the
* URL doesn't have to accept a search string.
*
* @param {string} keyword The typed keyword.
* @param {string} searchString The full search string, including the keyword.
* @returns { entry, url, postData }
Expand Down
8 changes: 4 additions & 4 deletions JS/openBookmarksHistoryEtcInNewTabs.uc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ==UserScript==
// @name Open Bookmarks, History, etc. in New Tabs
// @version 1.2.1
// @version 1.2.2
// @author aminomancer
// @homepage https://github.com/aminomancer/uc.css.js
// @description In vanilla Firefox, browser.tabs.loadBookmarksInTabs only
Expand Down Expand Up @@ -28,8 +28,8 @@
function init() {
if (window.PlacesUIUtils && !PlacesUIUtils._hasBeenModifiedForOBHNT) {
const lazy = {};
XPCOMUtils.defineLazyModuleGetters(lazy, {
PlacesUtils: "resource://gre/modules/PlacesUtils.jsm",
ChromeUtils.defineESModuleGetters(lazy, {
PlacesUtils: "resource://gre/modules/PlacesUtils.sys.mjs",
});
function getBrowserWindow(aWindow) {
return aWindow &&
Expand All @@ -42,7 +42,7 @@
PlacesUIUtils.openNodeWithEvent
.toSource()
.replace(/\(function PUIU_openNodeWithEvent/, "")
.replace(/ && PlacesUtils\.nodeIsBookmark\(aNode\)/, "")
.replace(/ && lazy.PlacesUtils\.nodeIsBookmark\(aNode\)/, "")
.replace(/\)$/, "")
);
PlacesUIUtils._hasBeenModifiedForOBHNT = true;
Expand Down
6 changes: 4 additions & 2 deletions JS/urlbarMods.uc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ==UserScript==
// @name Urlbar Mods
// @version 1.7.0
// @version 1.7.1
// @author aminomancer
// @homepage https://github.com/aminomancer/uc.css.js
// @description Make some minor modifications to the urlbar. See the code
Expand Down Expand Up @@ -532,12 +532,14 @@ class UrlbarMods {
if (!src1.includes("client.clientType")) {
const lazy = {};
XPCOMUtils.defineLazyModuleGetters(lazy, {
PlacesUtils: "resource://gre/modules/PlacesUtils.jsm",
SyncedTabs: "resource://services-sync/SyncedTabs.jsm",
UrlbarPrefs: "resource:///modules/UrlbarPrefs.jsm",
UrlbarResult: "resource:///modules/UrlbarResult.jsm",
UrlbarTokenizer: "resource:///modules/UrlbarTokenizer.jsm",
});
ChromeUtils.defineESModuleGetters(lazy, {
PlacesUtils: "resource://gre/modules/PlacesUtils.sys.mjs",
});
eval(
`RemoteTabs.startQuery = async function ` +
src1
Expand Down

0 comments on commit b0664f2

Please sign in to comment.