From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.

(function(window, mw, $){

	$.getJSON('/?title=Special:MyPage/bookmarks.json&action=raw&ctype=application/json', function (bookmarks) {

		var bookmarkMenu = $('<nav>');

		bookmarkMenu.attr('id', 'p-bookmarks');

		bookmarkMenu.addClass('mw-portlet mw-portlet-tb vector-menu vector-menu-portal portal');

		bookmarkMenu.attr('aira-labelledby', 'p-bookmarks-label');

		bookmarkMenu.attr('role', 'navigation');

		

		var label = $('<label>');

		label.attr('id', 'p-bookmarks-label');

		label.addClass('vector-menu-heading');

		label.attr('aria-label', ''); // not sure if this should be blank, but all the other portlets are blank /shrug

		label.append('Bookmarks [<a href="/?title=Special:MyPage/bookmarks.json&action=edit">edit</a>]');

		

		bookmarkMenu.append(label);

		

		var listDiv = $('<div>');

		listDiv.addClass('body vector-menu-content pBody');

		

		var ul = $('<ul>');

		ul.addClass('vector-menu-content-list');

		

		for (var i = 0; i < bookmarks.length; i++) {

			var bookmark = bookmarksi];

			

			var li = $('<li>');

			li.attr('id', 'bookmark-'+i);

			li.addClass('mw-list-item');

			

			var a = $('<a>');

			a.attr('href', mw.util.getUrl(bookmark.url));

			

			var span = $('<span>');

			span.text(bookmark.name);

			a.append(span);

			

			if (typeof bookmark.accesskey === "string" && bookmark.accesskey.length === 1) {

				a.attr('accesskey', bookmark.accesskey)

			}

			

			li.append(a);

			ul.append(li);

		}

		

		listDiv.append(ul);

		bookmarkMenu.append(listDiv);

		bookmarkMenu.insertAfter('#p-tb');

	});

})(window, mw, $);