Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase the maximum size limit #360

Closed
YePpHa opened this issue Oct 15, 2014 · 14 comments · Fixed by #365
Closed

Increase the maximum size limit #360

YePpHa opened this issue Oct 15, 2014 · 14 comments · Fixed by #365
Labels
bug You've guessed it... this means a bug is reported. CODE Some other Code related issue and it should clearly describe what it is affecting in a comment. DB Pertains inclusively to the Database operations. enhancement Something we do have implemented already but needs improvement upon to the best of knowledge.

Comments

@YePpHa
Copy link

YePpHa commented Oct 15, 2014

I am the developer of YouTube Center and when I'm trying to update YouTube Center on OpenUserJS I'm met with a problem, which is caused by the maximum request size of the browser (Error: Request Entity Too Large).

The first time a userscript is created on OpenUserJS you have the ability to upload the userscript instead of copy/pasting it into a text field. I would request that this ability to upload the file will be added to the page when updating a userscript as YouTube Center minified has a size of ~2.3 MB (I know it's a lot, but it's also a big project).

Also I would probably be able to implement this feature into OpenUserJS myself, but I will just post this here before I begin to do a pull request.

@Martii
Copy link
Member

Martii commented Oct 15, 2014

I am the developer of YouTube Center and when I'm trying to update YouTube Center on OpenUserJS I'm met with a problem, which is caused by the maximum request size of the browser (Error: Request Entity Too Large).

The first time a userscript is created on OpenUserJS you have the ability to upload the userscript instead of copy/pasting it into a text field. I would request that this ability to upload the file will be added to the page when updating a userscript as YouTube Center minified has a size of ~2.3 MB (I know it's a lot, but it's also a big project).

Also I would probably be able to implement this feature into OpenUserJS myself, but I will just post this here before I begin to do a pull request.

For starters https://github.com/OpenUserJs/OpenUserJS.org/blob/3d78209c70dc58dabee4c12c6813781eb77e8b2c/models/settings.json#L4 is currently the maximum size.

Secondly we already have an upload file option at https://openuserjs.org/user/add/scripts (middle column and 2nd row down "Upload Script"). In your case it's definitely beyond the current ~488KiB limit. @sizzlemctwizzle will need to approve any maximum size if it is changed since he pays the bills.

Thirdly your script contains embedded images, css, and translations which would probably be better suited served outside of the user.js to minimize its drain on system and server resources (Think @resource and/or @require).

Fourthly are you saying you aren't getting a too large warning somewhere? e.g. have you successfully uploaded a ~2.3MiB file onto production?

Now that you have the appropriate info if you feel like changing the subject line to a feature request that might be prudent. As it stands now it is unclear and may merit an INVALID label with a close. Thanks.

See also:

@YePpHa YePpHa changed the title Add feature to update userscripts by uploading a new file Increase the maximum size limit Oct 15, 2014
@Martii Martii added enhancement Something we do have implemented already but needs improvement upon to the best of knowledge. DB Pertains inclusively to the Database operations. CODE Some other Code related issue and it should clearly describe what it is affecting in a comment. needs discussion Blah, blah, blah, wahh, wahh, wahh, etc. question A question has been encountered by anyone and has remained unanswered until cleared. labels Oct 15, 2014
@YePpHa
Copy link
Author

YePpHa commented Oct 15, 2014

I haven't seen that there was a setting to specify a maximum size limit, good to know. It's probably a good idea to present the file size limit to the user so there would be no confusion.

Thank you for pointing out that you can update your current userscript by using the same feature as uploading a new userscript. I would also think that it would be a good idea to meantion that too.

I was able to upload YouTube Center which exceeded the file size limit by using the upload button on https://openuserjs.org/user/add/scripts.
It's possible that there is a bug with the upload button or there it just doesn't check the file size.As you said the file size limit is at ~488KiB so there is most likely some kind of bug.

Also even if I remove the translations and assets the file size would still exceed the maximum file size limit. The way YouTube Center is designed it's not possible to load the translations and assets asynchronously without breaking a lot of stuff as it works a little different than an ordinary userscript.

I've changed the title to Increase the maximum size limit, which is probably more appropriate.

EDIT: I might be able to add the translation and assets to a separate javascript file with a variable that the will be accessible by using @require and then pass that variable through as an argument in the injection and then there shouldn't be problem.

@Martii Martii added bug You've guessed it... this means a bug is reported. and removed question A question has been encountered by anyone and has remained unanswered until cleared. labels Oct 15, 2014
@Martii
Copy link
Member

Martii commented Oct 15, 2014

I was able to upload YouTube Center which exceeded the file size limit

Confirmed. Target code bug at 1644a50#diff-664f851728e6fc6ec664075df484505cR74

Also even if I remove the translations and assets the file size would still exceed the maximum file size limit.

Always a possibility with larger scripts... however you should try. Your hosting on GH can allow for those to be hosted and referenced there and also cut down on the bandwidth for your users.

The way YouTube Center is designed it's not possible to load the translations and assets asynchronously without breaking a lot of stuff as it works a little different than an ordinary userscript.

@require and @resource is synchronous last I checked... what browser(s) are you supporting? You also appear to have some unique data URIs with PNGs that don't look right in base64. b64 is not known for small sizes too. Have you tried optimizing your images before you b64 them?

See also:

@YePpHa
Copy link
Author

YePpHa commented Oct 15, 2014

When you first mentioned that @require and @resource I forgot to think about that @require is like inserting JavaScript at the top of the page. So as I wrote in my edit I can possible create a new JavaScript file that would contain every asset and translation in variables (as is already done).

In recent changes to Firefox I've been forced to actually inject the whole YouTube Center script onto the page otherwise I wouldn't be able to access global JavaScript variables set by YouTube. So I could add the @require line and when I'm injecting the main script into the page I would also pass these variables from the new JavaScript file.

And as you also said I would be able to use Github to host the JavaScript file with the translations and assets. I could maybe also consider creating an empty JavaScript file with @require that linked to the main JavaScript file and in that way use Github as a host instead of OpenUserJS.

@Martii
Copy link
Member

Martii commented Oct 15, 2014

In recent changes to Firefox I've been forced to actually inject the whole YouTube Center script onto the page otherwise I wouldn't be able to access global JavaScript variables set by YouTube.

Have you tried Anthony's Content Scope Runner?


@resource should allow you to inject any text into the page scope as well.


I could maybe also consider creating an empty JavaScript file with @require that linked to the main JavaScript file and in that way use Github as a host instead of OpenUserJS.

Stubs/wrappers can work too. :)

@YePpHa
Copy link
Author

YePpHa commented Oct 15, 2014

Actually I've written a library that I'm using with YouTube Center that does the exact same thing as Anthony's Content Scope Runner and it also makes it possible to use the GM API (https://openuserjs.org/libs/YePpHa/UserProxy/).

@YePpHa
Copy link
Author

YePpHa commented Oct 15, 2014

I'm now using @require https://yeppha.github.io/downloads/YouTubeCenter.min.user.js instead of having the whole userscript hosted on OpenUserJS. In this way when the user installs YouTube Center they will download the file from https://yeppha.github.io/downloads/YouTubeCenter.min.user.js and the issue with the file size limit should be solved.

@Martii
Copy link
Member

Martii commented Oct 15, 2014

Kewl beans... let's leave this open for sizzle to see if he wants to change anything... I've fixered the bug you reported and awaiting redeploy. Thank you.

You still have some weird looking b64 data (clipped for brevity)

...
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
...

This would appear to be extra data and should have been tokenized by PNG if you optimized it... just a thought for a consideration of your users. :)

@YePpHa
Copy link
Author

YePpHa commented Oct 15, 2014

You're right it should've been tokenized. I will try to see if I can do something about it.

@sizzlemctwizzle
Copy link
Member

I had to set a maximum file size for uploads. If the value I chose isn't
enough for a legit script, I have no problem with increasing it.
On Oct 15, 2014 6:01 PM, "Marti Martz" notifications@github.com wrote:

Kewl beans... let's leave this open for sizzle to see if he wants to
change anything.

You still have some weird b64 data

...
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC
AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
...

clipped for brevity This would appear to be extra data and should have
been tokenized by PNG if you optimized it... just a thought for a
consideration of your users. :)


Reply to this email directly or view it on GitHub
#360 (comment)
.

@Martii
Copy link
Member

Martii commented Oct 17, 2014

When I tried the ~2.3MiB it took quite a while so that is probably something we should avoid.

My concern is that more people are using UTF-8 characters in their source in which our ~488KiB is at worst case is ~122KiB since it's four bytes per char... this assumes everything is extended characters which won't always be the case.

It would be awesome to expose/create the account creation date and have a timeout expiry on accounts... if they continue to keep logging in and contributing then we could increase this on the fly for certain users e.g. those who participate more based off their last contribution period but before expiry.

USO had a 1MiB limit so at worst case there 256KiB with all extended characters.

Just some thoughts out loud.


Tried one with pasting ~2.3 MiB source and got a dependency error from formidable on the request.


@YePpHa
Offtopic notification at https://openuserjs.org/libs/YePpHa/UserProxy/issues/Thoughts

Martii pushed a commit to Martii/OpenUserJS.org that referenced this issue Oct 19, 2014
* Same as USO was... recommend no higher to keep scripts legit and encourage use of `@require` and `@resource` for those types of scripts.

Closes OpenUserJS#360
Martii pushed a commit to Martii/OpenUserJS.org that referenced this issue Oct 22, 2014
* Spread some more icons around
* Add max file size upload value to mustache and show on script/lib upload page as an info alert. Mentioned at #OpenUserJS#360 (comment)

Applies to OpenUserJS#186
@Martii Martii removed the needs discussion Blah, blah, blah, wahh, wahh, wahh, etc. label Oct 26, 2014
@qsniyg
Copy link

qsniyg commented Sep 24, 2019

Would it be possible to have a case-by-case basis for the maximum script size? My userscript (which is currently hosted on greasyfork) currently sits at almost 3MB with comments, ~1.2MB without comments. It doesn't host any resources or any libraries, the size primarily comes from the ~3200 rules that exist in the script. Currently this fits under Greasyfork's 2MB limit, but I'm worried that within a year or so, it will surpass the limit as I find and add new rules to the script.

Using @require would technically work, but it would require creating one or more generally useless "libraries" (only useful to this userscript), that wouldn't alleviate server or user bandwidth in any way. It'd also make it harder for users (as well as myself) to modify the userscript and understand what's going on, and further complicate the rest of the project's uses.

@Martii
Copy link
Member

Martii commented Sep 25, 2019

@qsniyg

Presuming you don't have greater than four spaces in-between JavaScript quotes/apostrophes/back-ticks (String Literals) that you need to keep, and Linux or compatible conversion (or and editor that will do it for you)... I get this for your script when converting spaces to tabs keeping comments from your "smaller" hosted version on GF:

$ sed -e 's/    /\t/g' 'Image Max URL.user.js' > "Image Max URL.tabbed.user.js"
$ ls -l Image\ Max\ URL.*
*clipped*  915407 Sep 24 20:29 'Image Max URL.tabbed.user.js'  # 0.873000145 MiB
*clipped* 1162418 Sep 24 19:32 'Image Max URL.user.js'         # 1.108568192 MiB
$ awk "BEGIN {print (1.0 - 915407 / 1162418) * 100 }"
21.2498
$ # ... savings in percent (%) i.e. smaller

One note on publishing to OUJS if you import your script from GH it should be able to be within the limits since it's a direct copy instead of Ace/formidable adjusted, or run into #793, and briefly alluded to up here.

In short ... probably not, and it took about ~3-4 seconds for me to upload via file, but you have options atm.

You will also need to change the @license to Apache-2.0 for SPDX compliance and @icon is way too large atm (640x640 px units currently and max is 256x256 px units for rendered.... do a SVG?)... so the server will reject your script.

... sits at almost 3MB with comments

Not sure where you are getting this number from.

Stats:

$ ls -l Image\ Max\ URL*
*clipped* 2544836 Sep 24 21:25 'Image Max URL.full.tabbed.user.js'
*clipped* 2951990 Sep 24 21:22 'Image Max URL.full.user.js'
*clipped*    2609 Sep 24 20:00 'Image Max URL  imu.optimized.svg'
*clipped*    7497 Sep 24 21:14 'Image Max URL  imu.svg'
*clipped*   18591 Sep 24 21:27 'Image Max URL  logo.png'
*clipped*  915420 Sep 24 21:09 'Image Max URL.tabbed.user.js'
*clipped* 1162418 Sep 24 19:32 'Image Max URL.user.js'

Keep in mind when most, if not all, the browsers force stricter limits on storage for the .user.js engine managers you might have another issue.

@qsniyg
Copy link

qsniyg commented Sep 25, 2019

Alright, good to know, and thank you very much for the ideas, I hadn't even thought about spaces->tabs! :)

@OpenUserJS OpenUserJS locked as resolved and limited conversation to collaborators Apr 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug You've guessed it... this means a bug is reported. CODE Some other Code related issue and it should clearly describe what it is affecting in a comment. DB Pertains inclusively to the Database operations. enhancement Something we do have implemented already but needs improvement upon to the best of knowledge.
Development

Successfully merging a pull request may close this issue.

4 participants