top of page

Thanks to @ScratchFoxBot for helping me to make the codes ready for the bookmarklet and the bookmarklet itself

Create a bookmark and paste the following code in to the URL section.(Make sure that you removed the webpage URL from the bookmark before pasting this.)

Bugs:

1. If your username is shortened to

userna... or something similar then it will show [0 cats]. Try this is your profile page to see the real amount.

2. Can fail to display amount of cats if

there are so many usernames.

javascript:/* Made by ScratchFoxBot ( https://scratch.mit.edu/users/ScratchFoxBot/ )*/{var dictionary = {}; var list;function define(ele){ele.innerHTML = ele.innerHTML.replace(/<span style="color:rgb\(66, 226, 173\)"><b> \[\d* cats\]<\/b><\/span>/g, "");var name = ele.innerText.replace("by ", "").replace("@", "").trim().toLowerCase();if (dictionary[name] === undefined) dictionary[name] = [];dictionary[name].push(ele)}if (window.location.hostname == "scratch.mit.edu"){if (document.getElementsByClassName("user-name dropdown-toggle")[0] != undefined){ define(document.getElementsByClassName("user-name dropdown-toggle")[0]);}else if (document.getElementsByClassName("profile-name")[0] != undefined){ define(document.getElementsByClassName("profile-name")[0]);}if (window.location.href.includes("users")){ define(document.getElementsByTagName("h2")[0]);}Users = Array.prototype.filter.call(document.getElementsByTagName("a"), function(x){return /\/users\/[^\/]*\/?$/.test(x.href) && !/^(avatar thumb vertical|avatar|activity-li|user thumb item|flex-row mod-comment-message)$/.test(x.parentElement.className) && x.textContent != "Profile" && x.id != "comment-user" && !/^(creator-image)$/.test(x.className)});for (i = 0; i < Users.length; i++) define(Users[i]);{ Query(Object.keys(dictionary).join("+"), finalize);}if (document.querySelector("#comments > div:nth-child(2) > ul > div > span") != undefined){ document.querySelector("#comments > div:nth-child(2) > ul > div > span").innerHTML = "Load more<span style='color:rgb(66, 226, 173)'><b> (Won't Update Cats)</b></span>";}if (window.location.href.includes("scratch.mit.edu/messages") && !/(Logs)|(button)/.test(document.getElementsByClassName('messages-social-title')[0].innerHTML)){ document.getElementsByClassName('messages-social-title')[0].innerHTML = "<h4 class='messages-header'><span>Messages</span></h4> <button onclick='GetLogs(true,false)'>20 Logs</button> <button onclick='GetLogs(true,true)'>20 Logs involving me</button> <br> <button onclick='GetLogs(false,false)'>500 Logs</button> <button onclick='GetLogs(false,true)'>500 Logs involving me</button>"}}else alert("Run Cat Goggles on a scratch.mit.edu page");function Query(usernames, callback){var xmlHttp = new XMLHttpRequest;xmlHttp.onreadystatechange = function(){if (xmlHttp.readyState == 4 && xmlHttp.status == 200) callback(xmlHttp.responseText)};xmlHttp.open("GET", "https://smileycreations15.wixsite.com/cats-for-things/_functions/cats/" + usernames + "/v2.3", true);xmlHttp.setRequestHeader("Accept", "application/json");xmlHttp.send(null)}function finalize(response){var items = JSON.parse(response).items;var data = {};if (items != null){for (i = 0; i < items.length; i++){ data[items[i].account] = items[i].cats;}}var keys = Object.keys(dictionary);for (x = 0; x < keys.length; x++){if (Object.keys(data).includes(keys[x])){for (y = 0; y < dictionary[keys[x]].length; y++){ dictionary[keys[x]][y].innerHTML += (dictionary[keys[x]][y].parentElement.className == "info title" ? "<br>" : "") + '<span style="color:rgb(66, 226, 173)"><b> [' + data[keys[x]] + " cats]</b></span>";}}else{for (y = 0; y < dictionary[keys[x]].length; y++){ dictionary[keys[x]][y].innerHTML += '<span style="color:rgb(66, 226, 173)"><b> [0 cats]</b></span>';}}}}function GetLogs(limit, filter){ list = document.getElementsByClassName('messages-social-title')[0]; list.innerHTML = "<h4 class='messages-header'><span>Logs</span></h4>"; document.getElementsByClassName("messages-social-list")[0].innerHTML = ""; var element = document.getElementsByClassName("button messages-social-loadmore")[0]; if (element != undefined) { element.parentNode.removeChild(element); } var LogURL = "https://smileycreations15.wixsite.com/cats-for-things/_functions/GetLogs/"; if (limit) { LogURL += "20/"; } else { LogURL += "500/"; } if (filter) { var userN = document.getElementsByClassName('profile-name')[0].innerText.match(/\w+/)[0]; LogURL += userN; } fetch(LogURL, {method: "get"}).then(async (response) => {if (response.ok) { var json = await response.json();var logs = json.items;logs.forEach(AddLog);} else {alert ("Couldn't get logs");}}); }function AddLog(item){ var message = item.log.replace(/\[\w+\]/g, replacer); var stat = item['status'].replace(/\[\w+\]/g, replacer); if (stat == "none") { list.innerHTML += "<li style='color:rgb(66, 226, 173)'>" + timeSince(new Date(item.time)) + " ago: " + message + "</li><br><br>"; } else { list.innerHTML += "<li style='color:rgb(226, 92, 66)'>" + timeSince(new Date(item.time)) + " ago: " + message + "<br><b>Cause: " + stat + "</b></li><br><br>"; }}function replacer(Rmatch){ return "[" + "<a href='/users/" + Rmatch.match(/\w+/)[0] + "/'>" + Rmatch.match(/\w+/)[0] + "</a>" + "]"; }function timeSince(date){ date = new Date(date); var seconds = Math.floor((new Date() - date) / 1000); var interval = Math.floor(seconds / 31536000); if (interval > 1) { return interval + " years"; } interval = Math.floor(seconds / 2592000); if (interval > 1) { return interval + " months"; } interval = Math.floor(seconds / 86400); if (interval > 1) { return interval + " days"; } interval = Math.floor(seconds / 3600); if (interval > 1) { return interval + " hours"; } interval = Math.floor(seconds / 60); if (interval > 1) { return interval + " minutes"; } return Math.floor(seconds) + " seconds"; }};void(0);

bottom of page