// ==UserScript== // @name Shared Project Viewer // @namespace http://tampermonkey.net/ // @license MIT // @version 0.52 // @description Adds a page at scratch.mit.edu/shared to see projects people you follow have shared. // @author Mrcoat // @match *://scratch.mit.edu/* // @icon https://www.google.com/s2/favicons?sz=64&domain=scratch.mit.edu // @grant none // @downloadURL none // ==/UserScript== (function() { 'use strict'; // Your code here... if (window.location.href == "https://scratch.mit.edu/shared/" || window.location.href == "https://scratch.mit.edu/shared") { getToken().then( (value) => { start(value[0],value[1]); } ); const content = document.getElementById("content"); var link = document.createElement('link'); link.setAttribute('rel', 'stylesheet'); link.setAttribute('href', 'https://scratch.mit.edu/splash.css'); document.head.appendChild(link); content.innerHTML = '

Who shared what?

'; } else { const element = document.getElementsByTagName("ul")[0]; element.innerHTML = element.innerHTML + ''; console.log(element.innerHTML); } })(); async function getToken() { const response = await fetch("https://scratch.mit.edu/session/", {"headers": {"X-Requested-With":"XMLHttpRequest"}}); const session = await response.json(); return [session.user.token, session.user.username]; } function start(token,user) { const response = fetch("https://api.scratch.mit.edu/users/"+user+"/following/users/activity?limit=40&x-token="+token, {"headers": {"X-Requested-With":"XMLHttpRequest"}}) .then((response) => response.json()).then((data) => readData(data)); } function readData(data) { const list = document.getElementById("list"); for (let i=0;i
'; } } }