HCAWN / gcal-multical-event-merge

Browser extension that visually merges the same event on multiple Google Calendars into one event.
GNU General Public License v3.0
26 stars 5 forks source link

No longer works as a userscript #15

Open aspiers opened 1 year ago

aspiers commented 1 year ago

The Greasemonkey link is still in the README, but installing this way results in an error due to chrome.storage not being defined:

Uncaught TypeError: Cannot read properties of undefined (reading 'local')

I suspect that this may have been caused by 17ebadbcfb734be3a1af2f45863a2a58af570327, but I could easily be wrong.

It seems that devs have wanted userscripts to have access to chrome.storage for a very long time, but it never happened:

147233 - Give user scripts converted from extensions access to chrome.storage - chromium

andrewmacheret commented 8 months ago

I made a gist that fixes these problems:

  1. Remove usages of chrome.storage.local, this API only works for chrome extensions. as a consequence, you need to edit the script to change which style to use (i defaulted it to "candy cane")
  2. chroma.js was a dependency of this script, so I added it https://gist.github.com/andrewmacheret/e7833752a842c4657a997e04c09a037e
aminomancer commented 7 months ago

Should be pretty easy to just automatically replace instances of chrome.storage.local.get with GM.getValue and so on. And you don't need to include the text of chroma.js, as you can just add @require https://github.com/gka/chroma.js/blob/main/chroma-light.min.js

andrewmacheret commented 7 months ago

I made the @require change, updated the gist. That's a lot better, thank you for the suggestion!

For the other suggestion, I get the error GM.getValue is not a function when I tried using that function. However this is for remembering the user's style choice, but there's no UI in the greasemonkey script for changing the style, so I don't think it really matters.

aminomancer commented 7 months ago

You have to first get permission to use the function

@name ...
@require ...
@grant GM.getValue

GM.getValue("blahblah")

As for the UI, that's usually handled by the userscript manager. For example, violentmonkey has a Values tab for each script. But if you want, there's a settings UI library - GM_config.

aminomancer commented 6 months ago

I made the @require change, updated the gist. That's a lot better, thank you for the suggestion!

I think that @require directive doesn't actually work. You need the raw URL, not the viewer URL. But actually it's even better to use a CDN URL:

@require    https://cdn.jsdelivr.net/gh/gka/chroma.js/chroma-light.min.js