Skip to content

Instantly share code, notes, and snippets.

@joech4n
Last active July 15, 2020 11:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save joech4n/2c37e7f85c8ea849510d to your computer and use it in GitHub Desktop.
Save joech4n/2c37e7f85c8ea849510d to your computer and use it in GitHub Desktop.
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