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).
Offline
Yes... But how do you make a sign up and it saves?
Offline
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.
Offline
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
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?
Offline
Offline
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
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
Offline
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:
<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>
Offline
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.
Offline
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!

Offline
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!
Offline
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:
var username = $("#scrFrame").contents().find("#userbar strong a").html()Any advice?
Offline
Another thing might be SQL to save. That's what wordpress and phpBB do.
Offline
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!
Offline
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
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.
Offline
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!)

Offline
If you're interested, here is the source/docs for the Scratch API. You can authenticate a user this way:
http://scratch.mit.edu/api/authenticateuser?username=demo&password=demo123

Offline
Should we move this to Advanced Topics?
Offline
Bump.
Did you ever get it working?
Offline
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!
Offline
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!
Offline