3
3
// @version 0.2.1
4
4
// @description Useful Stuff
5
5
// @author GRA0007
6
+ // @contributor TheGameBuilder
6
7
// @match http://scratch.mit.edu/*
7
8
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
8
9
// @grant none
9
10
// ==/UserScript==
10
-
11
11
if ( document . URL . indexOf ( "mystuff/" ) >= 0 ) {
12
12
waitForKeyElements ( "#tabs" , appendSidebarItems ) ;
13
13
}
14
14
15
- if ( document . URL . indexOf ( "users/" ) >= 0 ) {
15
+ if ( document . URL . indexOf ( "users/" ) >= 0 ) {
16
16
waitForKeyElements ( "#featured-project" , liveFeaturedProject ) ;
17
17
}
18
18
@@ -21,8 +21,26 @@ function appendSidebarItems(jNode) {
21
21
}
22
22
23
23
function liveFeaturedProject ( jNode ) {
24
+ var $projName = $ ( '.project-name' ) ,
25
+ projID = Scratch . INIT_DATA . PROFILE . featuredProject . id ;
26
+ $ ( '.player .title' ) . css ( 'text-align' , 'center' ) ;
27
+ $projName . html ( $projName . html ( ) . trim ( ) ) ; //Make sure no whitespaces interefere with centering
28
+
24
29
jNode . remove ( ) ;
25
- var projID = Scratch . INIT_DATA . PROFILE . featuredProject . id
26
- var usid = Scratch . INIT_DATA . PROFILE . featuredProject . creator
27
- $ ( ".stage" ) . append ( "<iframe allowtransparency='true' width='282' height='210' src='http://scratch.mit.edu/projects/embed/" + projID + "/?autostart=true' frameborder='0' allowfullscreen=''></iframe>" ) ;
30
+
31
+ $ ( ".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>" ) ;
32
+
33
+ $ ( '.stage iframe' ) . load ( function ( ) {
34
+ var is404 = $ ( this ) . contents ( ) . find ( '#page-404' ) . length > 0 ;
35
+ if ( is404 ) {
36
+ $ ( '.stage div' ) . css ( 'height' , '211px' ) ;
37
+ $ ( this ) . css ( 'margin-top' , '-14px' ) ;
38
+ $ ( this ) . attr ( 'height' , '239' ) ;
39
+ $ ( this ) . attr ( 'src' , 'http://phosphorus.github.io/app.html?id=' + projID ) ;
40
+ }
41
+ else if ( $ ( this ) . attr ( 'src' ) . indexOf ( 'http://scratch.mit.edu/projects/embed/' ) > - 1 ) {
42
+ setTimeout ( function ( ) { $ ( '.stage iframe' ) . attr ( 'height' , '238' ) ; } , 200 ) ;
43
+ }
44
+ } ) ;
45
+ $ ( '.stage iframe' ) . attr ( "src" , "http://scratch.mit.edu/projects/embed/" + projID + "/?autostart=true" ) ;
28
46
}
0 commit comments