Custom-JavaScript-for-Websites-2 icon indicating copy to clipboard operation
Custom-JavaScript-for-Websites-2 copied to clipboard

Size limit?

Open darkzbaron opened this issue 6 years ago • 8 comments

Hi there,

There seems to be some size limit. If I use a long script, it does not save and therefore does not work.

I guess this is due to the Chrome Storage API limit? It is however annoying that there is no debuggin nor option to save the script as a local one.

My solution was to have CJS1 to run in parallel.

darkzbaron avatar Dec 04 '17 12:12 darkzbaron

Thank you for your feedback!

Yup, this is an issue but there are workaround for this:

My previous response on Chrome Webstore.

I'm sorry, there are constraints by chrome.storage API. There're tradeoff between sync scripts across devices and max script size. I think the smooth experience across different devices is more important.

If you really have huge script to run, I suggest you use third party website to host your real code. And write small code to load your script like mine: https://github.com/xcv58/toggle-leetcode-ac/blob/master/toggle-display-leetcode-bookmarklet.js

Thanks for your feedback!

It can provide a better experience to use Github/Gist to host larger codes and embeds the URL in this extension.

I create follow up issues: #26 #27 to solve the issue.

xcv58 avatar Dec 04 '17 17:12 xcv58

Related to #32

xcv58 avatar Dec 14 '17 05:12 xcv58

Run local web server like AppServ, Xamp

piccorocoso avatar Jan 21 '18 14:01 piccorocoso

I have found a much easier way to get around this issue, for most cases. Write your large script and store it on dropbox. On dropbox, copy the "dropbox link". If you enter this link in a browser, it will take you to a dropbox styled preview window. If you now replace www with dl, you get the raw text file. In the extension, click the add your own external scripts button, and paste the link you got. Make sure it starts with //dl.dropboxusercontent.com. No http(s) or www, it won't work with that. Now simply edit the file you put on dropbox so that all the code is inside a function that you can call, and call those functions from the extension. That's all that's to it.

Timmiej93 avatar May 08 '19 18:05 Timmiej93

@Timmiej93 Looks like the dropbox as add your own external scripts doesn't work anymore, as nothing happens at all. @xcv58 Neither does the workaround exemplified in the toggle-leetcode-ac post above. CSP complains: image

Any thoughts or ideas? Without the ability of using a larger script, I can't do what I was hoping to do.

Thanks in advance!

hugo-azevedo avatar Feb 19 '23 12:02 hugo-azevedo

@hugo-azevedo The Content Security Policy (CSP) is configured by Dropbox so we have no control. It seems there is a workaround for it:

customjsReady('body', function(element) {
  fetch('https://gist.githubusercontent.com/xcv58/5aaeda690ace2f468d51dbf9c65a3980/raw/a8b1c59223892fb2be08490b00c84fa4a029bb8e/test.js')
    .then((res) => res.text())
    .then((js) => {
      console.log('works in fetch', js)
      eval(js);
    })
});

I tried this and it works as expected: image

But it might not work anytime if Dropbox tighten their CSP.

xcv58 avatar Feb 19 '23 19:02 xcv58

@xcv58 Thank you so much for the help and the prompt reply. Many thanks!

hugo-azevedo avatar Feb 19 '23 22:02 hugo-azevedo

@hugo-azevedo The Content Security Policy (CSP) is configured by Dropbox so we have no control. It seems there is a workaround for it:

customjsReady('body', function(element) {
  fetch('https://gist.githubusercontent.com/xcv58/5aaeda690ace2f468d51dbf9c65a3980/raw/a8b1c59223892fb2be08490b00c84fa4a029bb8e/test.js')
    .then((res) => res.text())
    .then((js) => {
      console.log('works in fetch', js)
      eval(js);
    })
});

I tried this and it works as expected: image

But it might not work anytime if Dropbox tighten their CSP.

This method doesn't work when the site has a CSP that denies it. Do you have other suggestions?

BoyCoded avatar Nov 23 '23 16:11 BoyCoded