Skip to content
This repository was archived by the owner on May 30, 2021. It is now read-only.

Commit f9a0c88

Browse files
committed
No project Top Bar & Phosphorus Loading
Featured projects now automatically load with Phosphorus if iFrame page yields 404 (unshared and deleted projects). Project's top bar is now hidden as to leave more room for the project. PS: The css and height attribute changes are there to work around a glitch that cuts off the bottom of the iFrame. PS²: This is a merge from the PR I made to GRA0007's originals folder.
1 parent 3b10e00 commit f9a0c88

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

parts/profileenhancer.part.js

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,27 @@ msuParts["profileEnhancer"] = function (ScratchUserscript) {
116116
if (settings.liveProject) {
117117
//Make project live
118118
$("#featured-project").remove();
119-
var projID = unsafeWindow.Scratch.INIT_DATA.PROFILE.featuredProject.id;
120-
$(".stage").append("<iframe allowtransparency='true' width='282' height='210' src='http://scratch.mit.edu/projects/embed/" + projID + "/?autostart=true' frameborder='0' allowfullscreen=''></iframe>");
119+
var $projName = $('.project-name'),
120+
projID = unsafeWindow.Scratch.INIT_DATA.PROFILE.featuredProject.id;
121+
122+
$projName.html($projName.html().trim()); //Make sure no whitespaces interefere with centering
123+
$('.player .title').css('text-align', 'center');
124+
125+
$( ".stage" ).append( "<div style='overflow: hidden; height: 216px;' id='applet'><iframe style='margin-top: -25px;' allowtransparency='true' width='282' height='237' frameborder='0' allowfullscreen=''></iframe></div>" );
126+
127+
$('.stage iframe').load(function(){
128+
var is404 = $(this).contents().find('#page-404').length > 0;
129+
if(is404) {
130+
$('.stage div').css('height', '211px');
131+
$(this).css('margin-top', '-14px');
132+
$(this).attr('height', '239');
133+
$(this).attr('src', 'http://phosphorus.github.io/app.html?id=' + projID);
134+
}
135+
else if($(this).attr('src').indexOf('http://scratch.mit.edu/projects/embed/') > -1) {
136+
setTimeout(function(){$('.stage iframe').attr('height', '238');}, 200);
137+
}
138+
});
139+
$('.stage iframe').attr("src", "http://scratch.mit.edu/projects/embed/" + projID + "/?autostart=true");
121140
}
122141
}
123-
};
142+
};

0 commit comments

Comments
 (0)