Skip to content

Instantly share code, notes, and snippets.

@saihoooooooo
Created August 24, 2012 07:23
Show Gist options
  • Save saihoooooooo/3447066 to your computer and use it in GitHub Desktop.
Save saihoooooooo/3447066 to your computer and use it in GitHub Desktop.
greasemonkey coffeescript
//;###
// ==UserScript==
// @name coffeetest
// @namespace http://example.com/coffeetest
// @include *google.co.jp*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
// @require http://jashkenas.github.com/coffee-script/extras/coffee-script.js
// @version 1
// ==/UserScript==
eval(CoffeeScript.compile((<r>
# coffeescript from here ###
class Hip
constructor: ->
@usound = 'BURI!BURI!'
@hsound = 'BOO!'
unko: ->
console.log @usound
@
he: ->
console.log @hsound
@
class SuperHip extends Hip
constructor: ->
@usound = 'BURI!!!!!!BURI!!!!!!'
@hsound = 'BOO!!!!!!'
(new SuperHip()).he().unko()
# end of coffeescript #</r>).toString()));
@tagliala
Copy link

tagliala commented Mar 6, 2014

Does it work for you?

I had to use

eval(CoffeeScript.compile((function(){/**
# Start of CoffeScript

# End of CoffeeScript
**/}).toString().split('\n').slice(1, -1).join('\n')));

@joech4n
Copy link

joech4n commented Apr 5, 2018

From greasemonkey/greasemonkey#1529 (comment) :

Update: Looks like I need to use @require http://coffeescript.org/v2/browser-compiler/coffeescript.js per CoffeeScript docs. Here's an updated working example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment