Skip to content

Commit

Permalink
Update index.html
Browse files Browse the repository at this point in the history
  • Loading branch information
hcr5 authored Feb 17, 2024
1 parent 58f6da6 commit 5dbb4dc
Showing 1 changed file with 34 additions and 44 deletions.
78 changes: 34 additions & 44 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,51 +1,41 @@
<!DOCTYPE html>
<html lang="en">
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Scratch Followers Page</title>
<title>Scratch Followers</title>
<script src="https://code.jquery.com/jquery-latest.min.js"></script>
<script>
function loadFollowers() {
var username = document.getElementById('username').value.trim();
if (username === '') {
alert('Please enter a username.');
return;
}
var page = 1;

function load() {
$.get("https://cors-anywhere.herokuapp.com/http://scratch.mit.edu/users/" + username + "/followers/?page=" + page, loaded);
}

function loaded(data) {
var $dom = $(data);
var $users = $dom.find('span.title').children();
var $out = $('#result');

for (var i = 0; i < $users.length; i++) {
var user = $users[i].text.trim();
$out.append(user + '<br>');
}

page++;
if ($users.length > 0) {
load();
}
}

$('#result').empty(); // Clear previous results
load();
}
</script>
</head>
<body>
<h1>Scratch Followers Page</h1>
<div>
<label for="username">Enter Scratch Username:</label>
<input type="text" id="username" name="username">
<button onclick="loadFollowers()">Fetch Followers</button>
</div>
<div id="result"></div>

<input type="text" id="username" placeholder="Enter Username">
<button onclick="loadFollowers()">Load Followers</button>
<div id="result"></div>

<script>
function loadFollowers() {
var username = document.getElementById("username").value;
var page = 1;

function load() {
$.get("https://scratch.mit.edu/users/" + username + "/followers/?page=" + page, loaded);
}

function loaded(data) {
var $dom = $(data);
var $users = $dom.find('span.title > a');
var $out = $('#result');

for (var i = 0; i < $users.length; i++) {
var user = $($users[i]).text().trim();
$out.append(user + '<br>');
}

page++;
$.get("https://scratch.mit.edu/users/" + username + "/followers/?page=" + page, loaded);
}

load();
}
</script>

</body>
</html>

0 comments on commit 5dbb4dc

Please sign in to comment.