I've been thinking about building a very simple extension...

Add-ons for Pale Moon and other UXP Applications
General discussion, compatibility, contributed extensions, themes, plugins, and more.

Moderators: FranklinDM, Lootyhoof

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 30853
Joined: 2011-08-28, 17:27
Location: Tranås, SE
Contact:

Re: I've been thinking about building a very simple extension...

Unread post by Moonchild » 2021-07-28, 00:58

BenFenner wrote:
2021-07-27, 17:18
would there be a good suggestion as to which extension to fork to begin learning?
New Tobin Paradigm wrote:
2021-07-27, 19:00
ffs just go away and stop wasing everyone's time if you aren't going to shut up, buckle down, and do something productive.
IOW stop asking to be handed a measured task on a silver platter.
Just go through the list, dive in, download some extensions people have asked to be forked, and LOOK AT THEM.
I'm sure you can figure out from there what will be within your grasp and what won't be. In the end you will have to do the work, anyway, we're not going to pre-chew it.
"Just because you know something is going to break in the end, doesn't mean that it can't have an effect that lasts into the future. Joy. Wonder. Laughter. Hope. The world can be better because of what you built in the past." -- Tom Scott
Image

User avatar
Kathuluforz
Lunatic
Lunatic
Posts: 369
Joined: 2019-06-13, 13:42
Location: In a place with no YT

Re: I've been thinking about building a very simple extension...

Unread post by Kathuluforz » 2021-07-28, 04:16

Even as a relatively new user of PM I totally agree with Moonchild and Tobin on this; Ever hear of reverse engineering? Take it apart (carefully)
see what makes it tick, then reassemble to working order or upgraded (hopefully) either hit or miss you will learn something about it.

There has been much info provided in this thread, Kudos to all that contributed, wonderful resources to look at for reference and help
I certainly will be making use of it when I can, as I have so far made 2 FF extensions (so far) PM compatible following the simple instructions
available on the forum, granted they were relatively simple extensions but I still have not worked out the licensing for them Yet
But I will eventually (I just haven't seen any licensing info as yet in the folders/files I have looked at, but I have not looked at all of
them yet).

And there are other files I want to get a better look at like some have js files, and I will tackle that when I can.
But the thing is, I can find all the info I need here in this thread and a few others on the forum, and there are always external sources
on the net that one can find if willing to search.

I would be further along in finishing the 2 extensions if I weren't so busy lately with family coming to visit me soon.
but after then I hope to have time to finish them and upload (with approval and correctly done) and announce, but only when ready.

I still have much to do but I know I can do it (given the time) and then once I feel I have become familiar enough with the code
(syntax/usage etc) I will do some others until I can make my own from scratch eventually (The Ideal)

But really anyone can do it given the desire, drive...and time :problem:

Edit: The ext's mentioned are not jetpack or other forbidden as far as I have seen, so far they both work as expected.
Pale Moon 29.4.1 (64) Win7 pro (64)

"People will come to love their oppression, to adore the technologies that undo their capacities to think." ~ Aldous Huxley

"Man needs difficulties; they are necessary for health." ~Carl Jung

User avatar
moonbat
Knows the dark side
Knows the dark side
Posts: 3401
Joined: 2015-12-09, 15:45
Contact:

Re: I've been thinking about building a very simple extension...

Unread post by moonbat » 2021-07-29, 07:01

New Tobin Paradigm wrote:
2021-07-27, 14:32
No, because arbitrary content script injection is a rather advanced topic I have yet to master.
I used a variation of this in my initial versions of Pure URL, in a bid to mimic the original Jetpack way of injecting the page modifying script. Later I figured how to just directly control the page without doing all this.
"One hosts to look them up, one DNS to find them and in the darkness BIND them."

Image
Linux Mint 20.1 Xfce x64 on HP i5-5200 laptop, 12 GB RAM.
AutoPageColor|PermissionsPlus|PMPlayer|Pure URL|RecordRewind|TextFX

User avatar
New Tobin Paradigm
Knows the dark side
Knows the dark side
Posts: 10473
Joined: 2012-10-09, 19:37
Location: The Seriphia Galaxy

Re: I've been thinking about building a very simple extension...

Unread post by New Tobin Paradigm » 2021-07-29, 08:48

Come on.. This is not what I want at all.. I want a generic method of loading a script into content ala userscript with the effect of using scratchpad and hitting execute. I don't want or need communication just when url == someURL put it in the page and eval.

This is eq of jepack or webex's content script or a greasemonkey userscript.
The avalanche has already started. It is too late for the pebbles to vote.
Image

User avatar
moonbat
Knows the dark side
Knows the dark side
Posts: 3401
Joined: 2015-12-09, 15:45
Contact:

Re: I've been thinking about building a very simple extension...

Unread post by moonbat » 2021-07-29, 13:11

Looking at Greasemonkey or Guerilla scripting doesn't help?
"One hosts to look them up, one DNS to find them and in the darkness BIND them."

Image
Linux Mint 20.1 Xfce x64 on HP i5-5200 laptop, 12 GB RAM.
AutoPageColor|PermissionsPlus|PMPlayer|Pure URL|RecordRewind|TextFX

User avatar
RealityRipple
Lunatic
Lunatic
Posts: 434
Joined: 2018-05-17, 02:34
Location: Los Berros Canyon, California
Contact:

Re: I've been thinking about building a very simple extension...

Unread post by RealityRipple » 2021-07-29, 14:08

Not sure if I missed some of what you're asking for, but this is how I added a new event class to relevant pages in my ADPC extension:

Code: Select all

function executePageScript(doc, script) {
 let eScr = doc.createElement('script');
 eScr.textContent = script;
 doc.head.appendChild(eScr);
 eScr.remove();
}
If you don't use doc.head for the append location, you should be able to do chrome-level insertion the same way.

User avatar
New Tobin Paradigm
Knows the dark side
Knows the dark side
Posts: 10473
Joined: 2012-10-09, 19:37
Location: The Seriphia Galaxy

Re: I've been thinking about building a very simple extension...

Unread post by New Tobin Paradigm » 2021-07-29, 17:56

That would be subject to CSP. I don't want to mess with dom to do it nor do i want to have it breaking context or executing from chrome.. So no.. Not your way, not JustOff's way..
New Tobin Paradigm wrote:
2021-07-27, 14:32
I know thus far that the Jetpack method internally uses the js sandbox and subscript loader features to do it like the JS Scratchpad does. It also seems GreaseMonkey uses the same mechinism as well but both are encumbered by their associated functions surrounding them so isolating ONLY what I need has been a bit of a bitch.
This way, which I already said. Too bad no one bothered to read it or try and create it when I asked months ago.

To add to it only the various JS Scratchpad incarnations and our Jetpack internals can only be reasonably used because Greasemonkey and that other extension's licensing isn't compatible for taking code from.
The avalanche has already started. It is too late for the pebbles to vote.
Image

User avatar
RealityRipple
Lunatic
Lunatic
Posts: 434
Joined: 2018-05-17, 02:34
Location: Los Berros Canyon, California
Contact:

Re: I've been thinking about building a very simple extension...

Unread post by RealityRipple » 2021-07-29, 19:45

Off-topic:
My example uses direct script source code (textContent), not a referenced file (src attribute), so no direct CSP there (unless the script further references something external), and it deletes the element immediately after it's been added, so it doesn't permanently alter the DOM structure (unless the script does), and only runs in the context of its parent because of the way it's inserted as an element, so no breaking context, but I get why both of those (direct source and dom restructuring twice) could be no-gos in many situations.

As far as I know, the NS-interface-based script insertion stuff is generally detailed in XUL School Appendix D, with mozIJSSubScriptLoader's loadSubScript() function providing a way to load a script file into a specified context. There are other interfaces (nsIFrameScriptLoader and nsIProcessScriptLoader) for more complicated contexts, but I get the feeling mozIJSSubScriptLoader is probably enough for most tasks. Note that this is local-only (chrome:, resource: or file:), while the other interfaces mentioned can handle data: and maybe some other fun stuff, but are for much more specific purposes.

User avatar
New Tobin Paradigm
Knows the dark side
Knows the dark side
Posts: 10473
Joined: 2012-10-09, 19:37
Location: The Seriphia Galaxy

Re: I've been thinking about building a very simple extension...

Unread post by New Tobin Paradigm » 2021-07-29, 20:30

I know all this already. I want a basic bootstrap extension that can be easily modified with a specified script to match a URL and whenever a URL match is triggered by a navigation event by whatever criteria it injects the content script. Something that can be used for a dead easy script injection example and single extension userscript-type packaging (but not the gm declaration processing) that is UXP web client agnostic.
The avalanche has already started. It is too late for the pebbles to vote.
Image

User avatar
RealityRipple
Lunatic
Lunatic
Posts: 434
Joined: 2018-05-17, 02:34
Location: Los Berros Canyon, California
Contact:

Re: I've been thinking about building a very simple extension...

Unread post by RealityRipple » 2021-07-29, 21:07

Egh... oogh... There's a lot of places that could go very bad if implemented wrong. No matter what you do, there's a chance that it'll mess something up in one use case or another. If you don't insert it directly into the DOM by adding the text during an nsITraceableChannel's onStopRequest, chances are it won't be there to catch any onLoad or similar events, and if you do, it could really mess up DOM navigation or restructuring listeners, even if you do remove it afterward. Maybe provide multiple injection methods and let the script-writer choose their preferred method, or add a blacklist/whitelist per method per site? Those both sound like tedious and messy choices, but I don't think there is a cleaner one that will cover everything.

User avatar
New Tobin Paradigm
Knows the dark side
Knows the dark side
Posts: 10473
Joined: 2012-10-09, 19:37
Location: The Seriphia Galaxy

Re: I've been thinking about building a very simple extension...

Unread post by New Tobin Paradigm » 2021-07-29, 21:08

I want the toolkit equivalent of the Jetpack content script method. AND THAT IS ALL I WANT. Since you can't or won't see that. Then please bow out if you aren't willing to help.
Last edited by New Tobin Paradigm on 2021-07-29, 21:10, edited 1 time in total.
The avalanche has already started. It is too late for the pebbles to vote.
Image

User avatar
RealityRipple
Lunatic
Lunatic
Posts: 434
Joined: 2018-05-17, 02:34
Location: Los Berros Canyon, California
Contact:

Re: I've been thinking about building a very simple extension...

Unread post by RealityRipple » 2021-07-29, 21:10

I can, I just don't think what you want is a thing at present. I'll keep an eye out as I work on the docs, but if something that can accomplish that exists, it might be more likely not documented, and something you'd have a better chance of finding in the IDL definitions directly...

User avatar
New Tobin Paradigm
Knows the dark side
Knows the dark side
Posts: 10473
Joined: 2012-10-09, 19:37
Location: The Seriphia Galaxy

Re: I've been thinking about building a very simple extension...

Unread post by New Tobin Paradigm » 2021-07-29, 21:12

Except it IS.. In Jetpack.. and Jetpack Internals can ONLY do what the platform allows. THUS it is possible and HAS been done in both pre-Jetpack JS Scratchpad and Greasemonkey. I just want an example that can be the basis for Site Specific Script Extensions that aren't encumbered and can be UXP Web Client agnostic.

I will probably figure it out in a few years BUT if this can be done before that.. Then it can also be used with a few more bits to effectively provide a path for those jetpack turned webextension fucktards that only care about script injecting content scripts and a dash of UI sprinkled on top. For me and what I specifically want I don't need those bits but yeah.

You see what I am getting at here? IT WOULD ALSO ALLOW SOMEONE TO ADAPT THE NON-WORKING USERSCRIPT OR RESULTING CODE THAT IS THE BASIS FOR UBLOCK'S (and Adblock Plus's) JS INJECTION FILTERS THAT ALLOW PEOPLE TO BYPASS GOOGLE'S NEW ADS SYSTEM ON YOUTUBE AS WELL..

So this would serve multiple imperatives and only advance collective goals.
The avalanche has already started. It is too late for the pebbles to vote.
Image

User avatar
RealityRipple
Lunatic
Lunatic
Posts: 434
Joined: 2018-05-17, 02:34
Location: Los Berros Canyon, California
Contact:

Re: I've been thinking about building a very simple extension...

Unread post by RealityRipple » 2021-07-29, 22:44

Yeah, I got what you were aiming for a few posts ago, like I said. But looking at the way Greasemonkey used to do this, and I think the way Scratchpad currently does, they may have pre-run every page's scripts in a sandbox and categorized them based on when they ran and what they hooked into or listened for, and kinda played it a little... messier than you're hoping for. I've never touched Jetpack, personally, so I have no idea what its underlying methods might be, but it could be more of the same. Not one or two clean interface function calls, in any case.

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 30853
Joined: 2011-08-28, 17:27
Location: Tranås, SE
Contact:

Re: I've been thinking about building a very simple extension...

Unread post by Moonchild » 2021-07-30, 11:18

You greatly overestimate scratchpad's complexity
"Just because you know something is going to break in the end, doesn't mean that it can't have an effect that lasts into the future. Joy. Wonder. Laughter. Hope. The world can be better because of what you built in the past." -- Tom Scott
Image

Post Reply