Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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