Skip to content

Instantly share code, notes, and snippets.

@mrjacobbloom
Created November 30, 2015 23:08
Show Gist options
  • Select an option

  • Save mrjacobbloom/1fea4aef1af5534795cc to your computer and use it in GitHub Desktop.

Select an option

Save mrjacobbloom/1fea4aef1af5534795cc to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name :package2: adder
// @version 0.1
// @description replaces :package2: with the bbcode for package
// @author NickyNouse
// @match https://scratch.mit.edu/discuss/*
// @grant none
// ==/UserScript==
/* jshint -W097 */
'use strict';
var test = document.getElementsByClassName("markItUpEditor");
if(test.length > 0){
var editor = test[0];
var emoticonFunc = function(){
editor.value = editor.value.replace(/:package2:/g, "[img[]]http[color=inherit]:[/color]//i67.tinypic.com/24wsdo6.png[/img[]]");
};
if(editor.onkeyup != null){
var delegate = editor.onkeyup;
editor.onkeyup = function(){
emoticonFunc();
delegate();
};
} else {
editor.onkeyup = emoticonFunc;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment