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

Commit

Permalink
Create followMyself.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Szammi committed Jul 14, 2015
1 parent cd66351 commit fb5c10a
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions originals/SzAmmi/followMyself.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//Run on: *//scratch.mit.edu/users/*/

url = window.location.href;
yourUsername = Scratch.INIT_DATA.LOGGED_IN_USER.model.username;
usernameFromURL = url.substring(url.lastIndexOf("users/")+6,url.lastIndexOf("/"));

if (typeof(localStorage['following_myself']) === "undefined") { localStorage['following_myself'] = false; }
divClass = localStorage['following_myself'] == "false" ? "follow-button button notfollowing blue" : "follow-button button following grey";
dataControl = localStorage['following_myself'] == "true" ? "unfollow" : "follow";

Scratch.changeStatusForMyself = function() {
if (localStorage['following_myself'] == "true") {
localStorage['following_myself'] = false;
return;
}
localStorage['following_myself'] = true;
}

$(".header-text").after('<div id="follow-button" class="buttons"><div class="' + divClass + '" data-control="' + dataControl + '" onClick="Scratch.changeStatusForMyself()"><span class="follow text"><span class="icon-sm follower white"></span>Follow</span><span class="unfollow text"><span class="icon-sm follower black"></span>Unfollow</span></div></div>');

0 comments on commit fb5c10a

Please sign in to comment.