Jump to content

User:Sportzpikachu/bookmarks.js

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by Sportzpikachu (talk | contribs) at 21:39, 31 May 2024. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

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.
mw.loader.using( 'mediawiki.util' )
	.then( () => fetch( '/w/index.php?title=Special:MyPage/bookmarks.json&action=raw&ctype=application/json' ) )
	.then( ( r ) => r.json() )
	.then( ( bookmarks ) => {
		mw.util.addPortlet( 'p-bookmarks', 'Bookmarks [edit]', 'p-tb' );
		document.getElementById( 'p-bookmarks-label' ).innerHTML = 
			'Bookmarks [<a href="/w/index.php?title=Special:MyPage/bookmarks.json&action=edit">edit</a>]';

		debugger;
		document.getElementById( 'p-tb' ).after(
			document.getElementById( 'p-bookmarks' )
		);
		
		for ( const bookmark of bookmarks ) {
			mw.util.addPortletLink(
				'p-bookmarks',
				mw.util.getUrl( bookmark.url ),
				bookmark.name,
				null,
				null,
				bookmark.accesskey,
			);
		}
	} );