Skip to content

Instantly share code, notes, and snippets.

@Zro617
Last active August 2, 2020 03:32
Show Gist options
  • Save Zro617/f4bab6eeaca5083ac217 to your computer and use it in GitHub Desktop.
Save Zro617/f4bab6eeaca5083ac217 to your computer and use it in GitHub Desktop.
Adds a navigational bar on some profile subpages
// ==UserScript==
// @author Zro617
// @name Scratch Profile Navbar
// @namespace zro617.github.io
// @description Adds a navbar to the profile subpages
// @include https://scratch.mit.edu/users/*/projects/
// @include https://scratch.mit.edu/users/*/favorites/
// @include https://scratch.mit.edu/users/*/studios/
// @include https://scratch.mit.edu/users/*/studios_following/
// @include https://scratch.mit.edu/users/*/following/
// @include https://scratch.mit.edu/users/*/followers/
// @version 1.1
// @grant none
// ==/UserScript==
var links = [
{
title: 'Projects',
href: '/projects/'
},
{
title: 'Favorites',
href: '/favorites/'
},
{
title: 'Studios Curating',
href: '/studios/'
},
{
title: 'Studios Following',
href: '/studios_following/'
},
{
title: 'Following',
href: '/following/'
},
{
title: 'Followers',
href: '/followers/'
},
];
var div = document.querySelector('div.box-head');
var user = div.querySelector('h2').querySelector('a').innerHTML;
var ul = document.createElement('ul');
ul.setAttribute('class', 'navprofile');
ul.setAttribute('style', 'list-style:none;');
for (var x in links) {
var li = document.createElement('li'),
a = document.createElement('a');
li.setAttribute('style', 'display:inline;margin:12px;');
a.setAttribute('href', 'https://scratch.mit.edu/users/' + user + links[x].href);
a.innerHTML = links[x].title;
li.appendChild(a);
ul.appendChild(li);
}
//div.appendChild(document.createElement("br"));
div.appendChild(ul);
@devxan
Copy link

devxan commented Aug 2, 2020

Okay, this is just awesome. Thanks for making this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment