This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2011-03-02 19:34:46

Rub0Gameton
Scratcher
Registered: 2008-03-30
Posts: 100+

Getting username from Scratch Website

Is there a way of getting the username in which you are logged in to Scratch? I tried through cookies, but it seems to be encrypted (The only thing encrypted should be the password). If not, is there a way to know what the line "Welcome, Username | Logout" is displaying? (I just need the username). I have knowledge over PHP, JS, HTML, CSS, and am starting to learn DOM (which may give the solution). Thanks in advance!

-If any1 wonders why I want to do this, it is because I'm creating an extension for Scratch (Go to Collab forums for more information on ScratchPlus) and I dont want people to create account for people that are not them. (F.E.: Me creating an account for andresmh).


Are you doing a collab and need a 24/7 TeamSpeak channel? Contact me... somewhere. =P

Offline

 

#2 2011-03-02 19:37:00

thebuilderdd
Scratcher
Registered: 2008-01-26
Posts: 1000+

Re: Getting username from Scratch Website

Yes... But how do you make a sign up and it saves?

Offline

 

#3 2011-03-02 19:42:36

Rub0Gameton
Scratcher
Registered: 2008-03-30
Posts: 100+

Re: Getting username from Scratch Website

thebuilderdd wrote:

Yes... But how do you make a sign up and it saves?

Ill answer that question the best way I understand it....
I just want to confirm that you are that person in Scratch, not an impersonificator, when the script confirms you are actually that person, you are available to sign up as HIM in an EXTERNAL server.


Are you doing a collab and need a 24/7 TeamSpeak channel? Contact me... somewhere. =P

Offline

 

#4 2011-03-02 19:44:14

thebuilderdd
Scratcher
Registered: 2008-01-26
Posts: 1000+

Re: Getting username from Scratch Website

Rub0Gameton wrote:

thebuilderdd wrote:

Yes... But how do you make a sign up and it saves?

Ill answer that question the best way I understand it....
I just want to confirm that you are that person in Scratch, not an impersonificator, when the script confirms you are actually that person, you are available to sign up as HIM in an EXTERNAL server.

Huh???

Offline

 

#5 2011-03-02 19:46:39

Rub0Gameton
Scratcher
Registered: 2008-03-30
Posts: 100+

Re: Getting username from Scratch Website

thebuilderdd wrote:

Rub0Gameton wrote:

thebuilderdd wrote:

Yes... But how do you make a sign up and it saves?

Ill answer that question the best way I understand it....
I just want to confirm that you are that person in Scratch, not an impersonificator, when the script confirms you are actually that person, you are available to sign up as HIM in an EXTERNAL server.

Huh???

Huh what?


Are you doing a collab and need a 24/7 TeamSpeak channel? Contact me... somewhere. =P

Offline

 

#6 2011-03-02 19:50:13

fourD
Scratcher
Registered: 2010-10-06
Posts: 49

Re: Getting username from Scratch Website

cookies are the answer.

Offline

 

#7 2011-03-02 19:52:52

thebuilderdd
Scratcher
Registered: 2008-01-26
Posts: 1000+

Re: Getting username from Scratch Website

Rub0Gameton wrote:

thebuilderdd wrote:

Rub0Gameton wrote:


Ill answer that question the best way I understand it....
I just want to confirm that you are that person in Scratch, not an impersonificator, when the script confirms you are actually that person, you are available to sign up as HIM in an EXTERNAL server.

Huh???

Huh what?

I don't get it...

Offline

 

#8 2011-03-02 19:53:09

Rub0Gameton
Scratcher
Registered: 2008-03-30
Posts: 100+

Re: Getting username from Scratch Website

fourD wrote:

cookies are the answer.

ok, but the username is encrypted! BTW, I noticed that the cookie in Scratch Resources is not encrypted, however I would prefer using the main Scratch Website


Are you doing a collab and need a 24/7 TeamSpeak channel? Contact me... somewhere. =P

Offline

 

#9 2011-03-02 22:01:24

fullmoon
Retired Community Moderator
Registered: 2007-06-04
Posts: 1000+

Re: Getting username from Scratch Website

The fastest way to do this would be to use jQuery (you should really try it if you haven't). Load scratch.mit.edu into an invisible iframe and when it's loaded tell jQuery to dig up the 'userbar' div, and within it there's a <strong> then a <a> tag (which contains your username), so:

Code:

<iframe src="http://scratch.mit.edu" id="scrFrame" style="display:none" onload="frameLoaded()"></iframe>
<script type="text/javascript">
function frameLoaded()
{
  var username = $("#scrFrame").contents().find("#userbar strong a").html()
  if(username === null)
  {
    //You're not logged in
  }
}
</script>

http://i302.photobucket.com/albums/nn100/fullmoon32/wow.jpg

Offline

 

#10 2011-03-02 22:11:07

Sunrise-Moon
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: Getting username from Scratch Website

fullmoon wrote:

The fastest way to do this would be to use jQuery (you should really try it if you haven't). Load scratch.mit.edu into an invisible iframe and when it's loaded tell jQuery to dig up the 'userbar' div, and within it there's a <strong> then a <a> tag (which contains your username), so:

Code:

<iframe src="http://scratch.mit.edu" id="scrFrame" style="display:none" onload="frameLoaded()"></iframe>
<script type="text/javascript">
function frameLoaded()
{
  var username = $("#scrFrame").contents().find("#userbar strong a").html()
  if(username === null)
  {
    //You're not logged in
  }
}
</script>

But then you'd be loading two webpages every time you visited a page on the site.


http://i1067.photobucket.com/albums/u427/HulKDzN/RebornBlade.png

Offline

 

#11 2011-03-03 08:03:47

fullmoon
Retired Community Moderator
Registered: 2007-06-04
Posts: 1000+

Re: Getting username from Scratch Website

Sunrise-Moon wrote:

fullmoon wrote:

The fastest way to do this would be to use jQuery (you should really try it if you haven't). Load scratch.mit.edu into an invisible iframe and when it's loaded tell jQuery to dig up the 'userbar' div, and within it there's a <strong> then a <a> tag (which contains your username), so:

Code:

<iframe src="http://scratch.mit.edu" id="scrFrame" style="display:none" onload="frameLoaded()"></iframe>
<script type="text/javascript">
function frameLoaded()
{
  var username = $("#scrFrame").contents().find("#userbar strong a").html()
  if(username === null)
  {
    //You're not logged in
  }
}
</script>

But then you'd be loading two webpages every time you visited a page on the site.

It's unfortunate that you have to load the page at all, but since it's a Chrome extension, it won't have to happen every time you navigate!


http://i302.photobucket.com/albums/nn100/fullmoon32/wow.jpg

Offline

 

#12 2011-03-03 18:42:22

Rub0Gameton
Scratcher
Registered: 2008-03-30
Posts: 100+

Re: Getting username from Scratch Website

fullmoon wrote:

The fastest way to do this would be to use jQuery (you should really try it if you haven't). Load scratch.mit.edu into an invisible iframe and when it's loaded tell jQuery to dig up the 'userbar' div, and within it there's a <strong> then a <a> tag (which contains your username), so:

Code:

<iframe src="http://scratch.mit.edu" id="scrFrame" style="display:none" onload="frameLoaded()"></iframe>
<script type="text/javascript">
function frameLoaded()
{
  var username = $("#scrFrame").contents().find("#userbar strong a").html()
  if(username === null)
  {
    //You're not logged in
  }
}
</script>

Wow... I hadn't thought of that! I'll test it when I get to my computer!


Are you doing a collab and need a 24/7 TeamSpeak channel? Contact me... somewhere. =P

Offline

 

#13 2011-03-05 15:48:07

Rub0Gameton
Scratcher
Registered: 2008-03-30
Posts: 100+

Re: Getting username from Scratch Website

Rub0Gameton wrote:

fullmoon wrote:

The fastest way to do this would be to use jQuery (you should really try it if you haven't). Load scratch.mit.edu into an invisible iframe and when it's loaded tell jQuery to dig up the 'userbar' div, and within it there's a <strong> then a <a> tag (which contains your username), so:

Code:

<iframe src="http://scratch.mit.edu" id="scrFrame" style="display:none" onload="frameLoaded()"></iframe>
<script type="text/javascript">
function frameLoaded()
{
  var username = $("#scrFrame").contents().find("#userbar strong a").html()
  if(username === null)
  {
    //You're not logged in
  }
}
</script>

Wow... I hadn't thought of that! I'll test it when I get to my computer!

It always appears as "null"... how strange. I think there is a syntax error in the next part of a code: 

Code:

var username = $("#scrFrame").contents().find("#userbar strong a").html()

Any advice?


Are you doing a collab and need a 24/7 TeamSpeak channel? Contact me... somewhere. =P

Offline

 

#14 2011-03-05 15:51:53

thebuilderdd
Scratcher
Registered: 2008-01-26
Posts: 1000+

Re: Getting username from Scratch Website

Another thing might be SQL to save. That's what wordpress and phpBB do.

Offline

 

#15 2011-03-05 15:56:02

Rub0Gameton
Scratcher
Registered: 2008-03-30
Posts: 100+

Re: Getting username from Scratch Website

thebuilderdd wrote:

Another thing might be SQL to save. That's what wordpress and phpBB do.

I dont think that has anything to do with my issue... or am I getting you wrong?
What I want is to get the username from the person logged in to Scratch so people can't create fake accounts in my server!


Are you doing a collab and need a 24/7 TeamSpeak channel? Contact me... somewhere. =P

Offline

 

#16 2011-03-05 15:57:22

thebuilderdd
Scratcher
Registered: 2008-01-26
Posts: 1000+

Re: Getting username from Scratch Website

Rub0Gameton wrote:

thebuilderdd wrote:

Another thing might be SQL to save. That's what wordpress and phpBB do.

I dont think that has anything to do with my issue... or am I getting you wrong?
What I want is to get the username from the person logged in to Scratch so people can't create fake accounts in my server!

SQL saves your data. I dont know how it does.

Offline

 

#17 2011-03-05 16:00:58

Rub0Gameton
Scratcher
Registered: 2008-03-30
Posts: 100+

Re: Getting username from Scratch Website

thebuilderdd wrote:

Rub0Gameton wrote:

thebuilderdd wrote:

Another thing might be SQL to save. That's what wordpress and phpBB do.

I dont think that has anything to do with my issue... or am I getting you wrong?
What I want is to get the username from the person logged in to Scratch so people can't create fake accounts in my server!

SQL saves your data. I dont know how it does.

Well yeah, Im using SQL, but that is not what my issue is about, I already know how to use SQL. The only thing I want is to get the username from the Scratch website! I can do the rest.


Are you doing a collab and need a 24/7 TeamSpeak channel? Contact me... somewhere. =P

Offline

 

#18 2011-03-05 16:47:00

fullmoon
Retired Community Moderator
Registered: 2007-06-04
Posts: 1000+

Re: Getting username from Scratch Website

Rub0Gameton wrote:

thebuilderdd wrote:

Another thing might be SQL to save. That's what wordpress and phpBB do.

I dont think that has anything to do with my issue... or am I getting you wrong?
What I want is to get the username from the person logged in to Scratch so people can't create fake accounts in my server!

To SQL-query the Scratch database you need password-protected access, which they don't give away easily!

I'll double check my jQuery to see if something's up.

EDIT: My bad! You can't access an iframe's contents in Javascript unless the frame and the page are on the same domain. I think I have another idea, though. You might try using jQuery.ajax to tell YQL to send the user's login info to the Scratch server and produce the resulting page. This would tell you whether the info the user provided you is right or not. That still is a lot of work...try contacting the Scratch team asking for permission to use their public login API (which exists, apparently!)


http://i302.photobucket.com/albums/nn100/fullmoon32/wow.jpg

Offline

 

#19 2011-03-07 22:24:30

fullmoon
Retired Community Moderator
Registered: 2007-06-04
Posts: 1000+

Re: Getting username from Scratch Website

If you're interested, here is the source/docs for the Scratch API. You can authenticate a user this way:

Code:

http://scratch.mit.edu/api/authenticateuser?username=demo&password=demo123

http://i302.photobucket.com/albums/nn100/fullmoon32/wow.jpg

Offline

 

#20 2011-03-08 08:01:22

helltank
Scratcher
Registered: 2010-05-21
Posts: 1000+

Re: Getting username from Scratch Website

Should we move this to Advanced Topics?


Error:Signature could not load. Please wait for an indefinite amount of time, until you realize you're gullible and go off to look for another potentially interesting signature to stare at.

Offline

 

#21 2011-04-10 09:43:27

johnnydean1
Scratcher
Registered: 2010-02-12
Posts: 1000+

Re: Getting username from Scratch Website

Bump.
Did you ever get it working?


You can now reach me on Twitter @johnnydean1_

Offline

 

#22 2011-04-14 20:39:58

Rub0Gameton
Scratcher
Registered: 2008-03-30
Posts: 100+

Re: Getting username from Scratch Website

fullmoon wrote:

If you're interested, here is the source/docs for the Scratch API. You can authenticate a user this way:

Code:

http://scratch.mit.edu/api/authenticateuser?username=demo&password=demo123

Thx! Ill try it out!


Are you doing a collab and need a 24/7 TeamSpeak channel? Contact me... somewhere. =P

Offline

 

#23 2011-04-15 09:33:45

Servine
Scratcher
Registered: 2011-03-19
Posts: 1000+

Re: Getting username from Scratch Website

I was trying this too. When logged in it can't scan, there is a way, but deep down in a technical code. I'm trying with pa..


I know!

When you post Panther picks up the user that posted! I'll just go off that!


http://bluetetrarpg.x10.mx/usercard/?name=Servine

Offline

 

Board footer