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 6139387 commit c15ce57
Showing 1 changed file with 19 additions and 21 deletions.
40 changes: 19 additions & 21 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,36 @@
<title>Scratch Followers Page</title>
<script src="https://code.jquery.com/jquery-latest.min.js"></script>
<script>
var page = 1;

function loadFollowers() {
var username = document.getElementById('username').value.trim();
if (username === '') {
alert('Please enter a username.');
return;
}
var page = 1;

$.ajax({
url: "https://scratch.mit.edu/users/" + username + "/followers/?page=" + page,
type: "GET",
success: function(data) {
loaded(data);
},
error: function(xhr, status, error) {
console.error("Error loading data:", error);
}
});
}
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');
function loaded(data) {
var $dom = $(data);
var $users = $dom.find('span.title').children();
var $out = $('#result');

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

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>
Expand Down

0 comments on commit c15ce57

Please sign in to comment.