aminought / firefox-second-sidebar

A Firefox userChrome.js script for adding a second sidebar with web panels like in Vivaldi/Floorp/Zen.
Mozilla Public License 2.0
77 stars 2 forks source link

[Feature Request] add loader to use other loader #5

Open dimdamin opened 1 week ago

dimdamin commented 1 week ago

Hi, can You add loader to use other loader, i use Xiao Fleaud my load script

// ==UserScript==
// @name            Firefox Second Sidebar
// @author          aminought
// @include         main
// @homepageURL     https://github.com/aminought/firefox-second-sidebar/tree/master
// @description     A Firefox userChrome.js script for adding a second sidebar with web panels like in Vivaldi/Floorp/Zen.
// ==/UserScript==

if (location.href.startsWith("chrome://browser/content/browser.x")) {
    (async url => {
        (await ChromeUtils.compileScript(`data:,"use strict";import("${url}").catch(console.error)`)).executeInGlobal(window);
    })(Services.io.newURI(Components.stack.filename).resolve("second_sidebar.uc.mjs"));
}
aminought commented 5 days ago

I'm sorry, I'm not really a web developer, and I don't understand some things. What exactly is going on in this code, and why doesn't it work without it?

aminought commented 5 days ago

I have done some research on the topic and tried the loader myself. To be honest, I wasn't very impressed, but that doesn't matter. I just can't see this script fitting into the codebase at the moment. However, I can include it in the installation instructions and mention you there.

dimdamin commented 5 days ago

Thank You. Yes you can... no more need, you use fx-config API

benzBrake commented 3 days ago

I'm using alice0775's loader. In addition to this script, I also need to modify second_sidebar.uc.mjs change

UC_API.Runtime.startupFinished().then(run);

to

run();
aminought commented 3 days ago

@benzBrake does this loader support *.mjs scripts?

benzBrake commented 3 days ago

@benzBrake does this loader support *.mjs scripts?

As far as I know, only fx-autoconfig adds the function of automatically loading mjs, and other Loaders require the script from @dimdamin

aminought commented 3 days ago

In addition to this script, I also need to modify second_sidebar.uc.mjs

I think I'll replace it with something like this:

if (typeof UC_API !== 'undefined') {
  UC_API.Runtime.startupFinished().then(run);
} else {
  run();
}
dimdamin commented 3 days ago

FYI

// ==UserScript==
// @name            Second Sidebar for Firefox
// @description     A Firefox userChrome.js script for adding a second sidebar with web panels like in Vivaldi/Floorp/Zen.
// @author          aminought
// @homepageURL     https://github.com/aminought/firefox-second-sidebar
// ==/UserScript==

import { SidebarDecorator } from "./second_sidebar/sidebar_decorator.mjs";
import { SidebarInjector } from "./second_sidebar/sidebar_injector.mjs";

//const run = () => {
(async () => {
  await delayedStartupPromise;
  SidebarInjector.inject();
  SidebarDecorator.decorate();
})();

//UC_API.Runtime.startupFinished().then(run);
aminought commented 3 days ago

await delayedStartupPromise;

It's not that simple.

dimdamin commented 3 days ago

This is an internal Firefox command in window and is available immediately when the script is loaded. The only thing left to do is to wait - “await window.delayedStartupPromise;” event “browser-delayed-startup-finished” P.S. It`s not example, it working script or working solution

aminought commented 2 days ago

OK:

if (typeof UC_API !== 'undefined') {
  UC_API.Runtime.startupFinished().then(run);
} else {
  delayedStartupPromise.then(run);
}
dimdamin commented 2 days ago

Firefox native function => work on all loader`szzzzz

(async () => {
  await delayedStartupPromise;
  SidebarInjector.inject();
  SidebarDecorator.decorate();
})();

native function work on all loader`szzzzz

delayedStartupPromise.then(run);

external function work only in fx-autoconfig

UC_API.Runtime.startupFinished().then(run);

please close this issues with don`t planet...

aminought commented 1 day ago

OK:

if (typeof UC_API !== 'undefined') {
  UC_API.Runtime.startupFinished().then(run);
} else {
  delayedStartupPromise.then(run);
}

OMG, this code works on all loaders.

aminought commented 1 day ago

Let's figure out something. This is a script for fx-autoconfig, which I'm only testing in this loader. However, I have tried to write the rest of the code, excluding second_sidebar.uc.mjs, so that it will be supported everywhere. For second_sidebar.uc.mjs, I have proposed a solution that will work everywhere, but will take advantage of fx-autoconfig when used.

@dimdamin I don't enjoy your way of communication. I'm starting to regret not using the fx-autoconfig API as much as possible.