Open SyfSchydea opened 1 year ago
One solution could be to have a python script like the patch-client one modify the code to add inclusions like that.
We could have generic systems like that in a lib/settings.js
file, then have comments in the code like /* !include lib/settings.js */
which the python script could find and replace with the contents of lib/settings.js
.
This would be quite a clean solution resulting in minimal code duplication.
The main downside would be that the source code could no longer simply be pasted directly into an extension like TamperMonkey to install it in the browser. Instead requiring an install step to convert source JS files (.src.js
or something?) into actually executable files.
The other would be to just include settings.js
as another script that gets included when installing the full suite of scripts. This wouldn't be quite so good for duplication, as you'd then need to include some repeated code in every script that uses it, to ensure that it's actually got the dependency it needs.
Some elements of the code have basically just been copied and pasted between several different scripts now. Eg, the Settings system.
It would be good for better code practices to have these sorts of generic systems in one place such that they can then be included and used in multiple scripts without having to duplicate their definitions.