Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save neoOpus/5ce5121f0a737a786ca25d162ea3c1e9 to your computer and use it in GitHub Desktop.
Save neoOpus/5ce5121f0a737a786ca25d162ea3c1e9 to your computer and use it in GitHub Desktop.
Tampermonkey user script templates
// ==UserScript==
// @name New Coffee-Userscript
// @namespace http://tampermonkey.net/
// @version 0.1
// @description shows how to use coffeescript compiler
// @author You
// @require http://coffeescript.org/extras/coffee-script.js
// @match <$URL$>
// @name Site - CoffeeScript
// @description CoffeeScript script
// @author James Skinner <[email protected]> (http://github.com/spiralx)
// @namespace http://spiralx.org/
// @version 0.0.1
// @icon http://tampermonkey.net/favicon.ico
// @match <$URL$>
// @grant none
// @run-at document-end
// @require https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.js
// @require https://rawgit.com/spiralx/653f2226b08167e4aaf8/raw/e830ed1ff2202102b91eb326f7826613ae9070ed/urijs-all.js
// @require http://coffeescript.org/extras/coffee-script.js
// ==/UserScript==
/* jshint ignore:start */
var inline_src = (<><![CDATA[
/* jshint ignore:end */
# Code...
/* jshint ignore:start */
]]></>).toString();
var compiled = this.CoffeeScript.compile(inline_src);
eval(compiled);
/* jshint ignore:end */
// ==UserScript==
// @name Site - Script
// @description ES6 script
// @author James Skinner <[email protected]> (http://github.com/spiralx)
// @namespace http://spiralx.org/
// @version 0.0.1
// @icon http://tampermonkey.net/favicon.ico
// @match <$URL$>
// @grant none
// @run-at document-end
// @require https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.js
// @require https://rawgit.com/spiralx/653f2226b08167e4aaf8/raw/e830ed1ff2202102b91eb326f7826613ae9070ed/urijs-all.js
// ==/UserScript==
/* jshint asi: true, esnext: true, -W097 */
(function($) {
'use strict'
// Code...
}).bind(this)(jQuery)
jQuery.noConflict()
// ==UserScript==
// @name Site - Script
// @description ES6 script
// @author James Skinner <[email protected]> (http://github.com/spiralx)
// @namespace http://spiralx.org/
// @version 0.0.1
// @icon http://tampermonkey.net/favicon.ico
// @match <$URL$>
// @grant none
// @run-at document-end
// @require https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.js
// @require https://rawgit.com/spiralx/653f2226b08167e4aaf8/raw/e830ed1ff2202102b91eb326f7826613ae9070ed/urijs-all.js
// @require https://cdnjs.cloudflare.com/ajax/libs/babel-core/6.1.19/browser.min.js
// ==/UserScript==
/* jshint ignore:start */
var inline_src = (<><![CDATA[
/* jshint ignore:end */
/* jshint asi:true, esnext:true, -W097 */
(function($) {
'use strict'
// Code...
}).bind(this)(jQuery)
jQuery.noConflict()
/* jshint ignore:start */
]]></>).toString();
//var c = babel.transform(inline_src);
var c = babel.transform(inline_src, {
filename: GM_info.script.name.replace(/\s+/g, '-').replace(/[^\w\-]+/g, '') + '.user.js',
sourceMaps: 'inline'
})
eval(c.code);
/* jshint ignore:end */
For
* ES5
* ES6
* CoffeeScript
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment