Closed luboq closed 1 year ago
Hi @waldens
Have you setup your userscript using the modern syntax as documented here? If yes, you could install the lib as a dependency and import it directly.
If you are not using the modern syntax, then at the moment, you won't be able to @require
it in your script as I have not added support for UMD modules. I will see if I get some time this week to add UMD support.
Thanks for reporting this.
Sorry for the late reply.
Maintaining this separate repository was becoming painful and I have been wanting to move it to my monorepo for a long time. Finally got time to do it and have also taken the opportunity to update (simplify) the API.
Along with that, I have also added support for UMD, CommonJS and ESM modules (default).
Some meta information of the package:
In favour of the new package, I will be deprecating this package and repo.
Following is the sample code to get you started in ViolentMonkey
// ==UserScript==
// @name New script - violentmonkey.github.io
// @namespace Violentmonkey Scripts
// @match *://*/*
// @grant none
// @version 1.0
// @author -
// @require https://cdn.jsdelivr.net/npm/@vighnesh153/github-gist/dist/umd.js
// @description 2/19/2023, 5:45:08 PM
// ==/UserScript==
const GithubGist = GithubGistUmd.GithubGist;
const gist = new GithubGist({
personalAccessToken: '',
appIdentifier: 'my-test-gist-2',
})
async function main() {
await gist.initialize();
const fileJson = gist.createNewFile('vighnesh153.json');
fileJson.content = JSON.stringify({ message: 'Vighnesh is the best' });
const filePython = gist.createNewFile('vighnesh153.py');
filePython.content = `print("Vighnesh is the best")`;
const fileJs = gist.createNewFile('vighnesh153.js');
fileJs.content = `console.log("Vighnesh is the best")`;
await gist.save();
const fileMd = gist.createNewFile('vighnesh153.md');
fileMd.content = '# Vighnesh is the best';
fileJs.content = [fileJs.content, 'console.log("Vighnesh is the best and I know it")'].join('\n');
await gist.save();
}
main()
I'm using Chrome + ViolentMonkey, and would like to use this lib in a userscript to read and write on GitHub Gist, is this possible?
If so, what URL should I reference in the @require of the metadata in userscript? Ty