Skip to content

Instantly share code, notes, and snippets.

@GeonoTRON2000
Created July 29, 2017 07:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GeonoTRON2000/42a453632c56c1acf8e48f4f03263663 to your computer and use it in GitHub Desktop.
Save GeonoTRON2000/42a453632c56c1acf8e48f4f03263663 to your computer and use it in GitHub Desktop.
Allow a Scratch 2.x project to be embedded in BBcode
// Usage: [scratch]projectID[/scratch]
var posts = document.getElementsByClassName("postmsg");
var pattern = /\[scratch\]([0-9]+)\[\/scratch\]/gi;
for (var i = 0; i < posts.length; i++) {
var post = posts[i];
post.innerHTML = post.innerHTML.replace(pattern, "<iframe allowtransparency=\"true\" width=\"485\" height=\"402\" src=\"http://scratch.mit.edu/projects/embed/$1/\" frameborder=\"0\" allowfullscreen></iframe>");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment