Skip to content

Instantly share code, notes, and snippets.

@joech4n

joech4n/^readme.md

Last active Jul 15, 2020
Embed
What would you like to do?
CoffeeScript in Greasemonkey

coffee1.user.js (in-line Coffeescript)

Based on method outlined in this comment

coffee2.user.js (separate .coffee file)

Based on approach outlined here.

  • Advantages

    Proper syntax highlighting, less noise and the possibility to have separate module files for bigger projects are a few advantages of that approach.

//;###
// ==UserScript==
// @name coffee test
// @description Example from https://gist.github.com/joech4n/2c37e7f85c8ea849510d
// @namespace https://gist.github.com/joech4n/2c37e7f85c8ea849510d
// @include https://gist.github.com/joech4n/2c37e7f85c8ea849510d
// @require http://coffeescript.org/v2/browser-compiler/coffeescript.js
// @version 1
// ==/UserScript==
CoffeeScript.eval((function(){/*
# coffeescript from here ###
console.log "test"
# end of coffeescript #*/}).toString().split("\n").slice(1, -1).join("\n"));
//;###
// ==UserScript==
// @name coffee test
// @description Example from https://gist.github.com/joech4n/2c37e7f85c8ea849510d
// @namespace https://gist.github.com/joech4n/2c37e7f85c8ea849510d
// @include https://gist.github.com/joech4n/2c37e7f85c8ea849510d
// @require https://greasemonkey.github.io/gm4-polyfill/gm4-polyfill.js
// @require http://coffeescript.org/v2/browser-compiler/coffeescript.js
// @resource coffee https://gist.github.com/joech4n/2c37e7f85c8ea849510d/raw/2de5d827c21aa67f06ba0633fee56edada425401/test.coffee
// @grant GM.getResourceText
// @grant GM_getResourceText
// @version 1
// ==/UserScript==
eval(CoffeeScript.compile(GM_getResourceText('coffee')));
console.log "test"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.