I made a small bookmarklet to open the experimental viewer in a different TAB, not window, because I didn't like how the link on the side opened a new window.
EDIT: The link below does not work. Use the source code to make a bookmarklet by 1) bookmarking this page, 2) renaming it to 'experimental', and 3) changing the url to what's in the code box below.
Experimental
javascript:var url = document.location.href;if (url.substr(0,32) == "http://scratch.mit.edu/projects/") {var lio = url.substring(0, url.lastIndexOf("/")).lastIndexOf("/");var part = url.substr(lio);window.open("http://scratch.mit.edu/experimental/viewproject"+part);} else {alert("I don't think this is a project page!")}Drag and drop into bookmarks bar.
To be able to use the viewer, go here
Last edited by Sidharth (2011-07-26 00:34:15)

Offline
JJROCKER wrote:
What is a bookmarklet?
A bookmarklet is a piece of javascript that can be saved as a bookmark so you can run it on any page. Since javascript can be written on one line, just type javascript:*your code here* and save that as the URL of a bookmark. When you click on it, your browser will execute it.

Offline
I see what you mean, pretty cool tho
Last edited by RUMCHEERYPOOPOO (2011-07-26 11:58:10)
Offline
Highlighting all the text in the code box and dragging it to the bookmark bar should work too.
Offline
You can also just enter it in the URL and you'll get a popup. I tried that, and it works!
<?php
function writeimageoftext($string, $subtext) {
// Set font size
$font_size = 2;
$font = realpath('aller.ttf');
// Create image width dependant on width of the string
$width = imagefontwidth($font_size)*strlen($string);
// Set height to that of the font
$height = imagefontheight($font_size);
if (isset($subtext)) {
$height = imagefontheight($font_size) + imagefontheight($font_size/2);
$lensub = strlen($subtext);
}
// Create the image pallette
$img = imagecreate($width,$height);
// Grey background
$bg = imagecolorallocate($img, 222, 223, 223);
// Black font color
$color = imagecolorallocate($img, 0, 0, 0);
// Length of the string
$len = strlen($string);
// Y-coordinate of character, X changes, Y is static
$ypos = 0;
// Loop through the string
for($i=0;$i<$len;$i++){
// Position of the character horizontally
$xpos = $i * imagefontwidth($font_size);
// Draw character
imagechar($img, $font_size, $xpos, $ypos, $string, $color);
// Remove character from string
$string = substr($string, 1);
}
if (isset($subtext)) {
$ypos = imagefontheight($font_size) + 1;
$font_size = $font_size / 2;
for($i=0;$i<$len;$i++){
// Position of the character horizontally
$xpos = $i * imagefontwidth($font_size);
// Draw character
imagechar($img, $font_size, $xpos, $ypos, $subtext, $color);
// Remove character from string
$subtext = substr($subtext, 1);
}
}
// Return the image
header("Content-Type: image/gif");
imagegif($img);
// Remove image
imagedestroy($img);
}
$mysql_host = "*****";
$mysql_database = "*****";
$mysql_user = "*****";
$mysql_password = "*****";
$topicid = $_REQUEST['id'];
$userip = $_SERVER['REMOTE_ADDR'];
if ($_REQUEST['ret'] == 'image') {
$topicid = $_REQUEST['id'];
if (is_numeric($topicid) === false) {
writeimageoftext('Error: id is not valid', '');
exit();
}
$url = 'http://scratch.mit.edu/forums/viewtopic.php?id=' . $topicid;
$urlcontents = trim(file_get_contents($url));
if (strpos($urlcontents, 'Badrequest') != false) { //badrequest should have a space inbetween but it breaks this page otherwise.
writeimageoftext('Error: id not found', '');
exit();
}
mysql_connect($mysql_host, $mysql_user, $mysql_password) or die(mysql_error());
mysql_select_db($mysql_database) or die(mysql_error());
$checkquery = mysql_query("SELECT * FROM topicrate WHERE postid='$topicid'");
if (mysql_num_rows($checkquery) == 0) {
$likes = 0;
}
else {
$topicratings = mysql_fetch_row($checkquery) or die(mysql_error());
$ratedips = explode(',', $topicratings[1]);
$likes = count($ratedips);
if ($ratedips[0] == '') {
$likes = 0;
}
}
if ($likes == 1) {
$likes = 1 . ' Like';
}
else {
$likes = $likes . ' Likes';
}
$checkquery = mysql_query("SELECT * FROM topicrate WHERE postid='$topicid'");
if (mysql_num_rows($checkquery) == 0) {
$already_liked = 'Like';
}
else {
$topicratings = mysql_fetch_row($checkquery) or die(mysql_error());
$ratedips = explode(',', $topicratings[1]);
$count = count($ratedips);
$already_liked = 'Like';
for($i=0; $i<$count; $i++) {
if($ratedips[$i] == $userip) {
$already_liked = 'Unlike';
}
}
}
writeimageoftext($likes, $already_liked);
}
elseif ($_REQUEST['ret'] == 'add') {
$headerurl = 'Location:http://scratch.mit.edu/forums/viewtopic.php?id=' . $topicid;
$topicid = $_REQUEST['id'];
mysql_connect($mysql_host, $mysql_user, $mysql_password) or die(mysql_error());
mysql_select_db($mysql_database) or die(mysql_error());
$checkquery = mysql_query("SELECT * FROM topicrate WHERE postid='$topicid'");
if (mysql_num_rows($checkquery) == 0) {
$addtopic_query = mysql_query("INSERT INTO topicrate (postid, ips) VALUES ('$topicid', '$userip')");
header($headerurl);
exit();
}
else {
$topicratings = mysql_fetch_row($checkquery) or die(mysql_error());
$ratedips = explode(',', $topicratings[1]);
$count = count($ratedips);
for($i=0; $i<$count; $i++) {
if($ratedips[$i] == $userip) {
unset($ratedips[$i]);
$ratedips = implode(',', $ratedips);
$updateips_query = mysql_query("UPDATE topicrate SET ips='$ratedips' WHERE postid='$topicid'") or die(mysql_error());
header($headerurl);
exit();
}
}
$ratedips[$count] = $userip;
$ratedips2 = implode(',', $ratedips);
if ($ratedips[0] == '') {
$ratedips2 = $userip;
}
$updateips_query = mysql_query("UPDATE topicrate SET ips='$ratedips2' WHERE postid='$topicid'") or die(mysql_error());
header($headerurl);
exit();
}
}
else {
writeimageoftext('Error: incorrect URL vars used', 'Better luck next time!');
}
?>It's super cool!
(He-he I changed it the tiniest bit- it now says something different)

Offline
horsenkat wrote:
You can also just enter it in the URL and you'll get a popup. I tried that, and it works!
WRONG CODE WAS HERE
It's super cool!
(He-he I changed it the tiniest bit- it now says something different)
![]()
I copied the wrong code. Nevermind. I didn't think before I posted. Sorry. Wish there was some way to delete posts...

Offline
horsenkat wrote:
horsenkat wrote:
You can also just enter it in the URL and you'll get a popup. I tried that, and it works!
WRONG CODE WAS HERE
It's super cool!
(He-he I changed it the tiniest bit- it now says something different)
![]()
I copied the wrong code. Nevermind. I didn't think before I posted. Sorry. Wish there was some way to delete posts...
Yes there is: look at the bottom right corner of your post.
But I think New Scratchers can't edit posts or delete them
Offline
sidharth_test wrote:
horsenkat wrote:
horsenkat wrote:
You can also just enter it in the URL and you'll get a popup. I tried that, and it works!
WRONG CODE WAS HERE
It's super cool!
(He-he I changed it the tiniest bit- it now says something different)
![]()
I copied the wrong code. Nevermind. I didn't think before I posted. Sorry. Wish there was some way to delete posts...
Yes there is: look at the bottom right corner of your post.
But I think New Scratchers can't edit posts or delete them![]()
LOL forgot to log off test acc

Offline