Jump to content

User:Sportzpikachu/bookmarks.js: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
inject hint
Tag: Reverted
No edit summary
Tag: Reverted
Line 3: Line 3:
.then( ( r ) => r.json() )
.then( ( r ) => r.json() )
.then( ( bookmarks ) => {
.then( ( bookmarks ) => {
const p = mw.util.addPortlet( 'p-bookmarks', 'Bookmarks [edit]', 'p-tb' );
mw.util.addPortlet( 'p-bookmarks', 'Bookmarks [edit]', 'p-tb' );
document.getElementById( 'p-tb' ).after( p );
document.getElementById( 'p-bookmarks-label' ).innerHTML =
document.getElementById( 'p-bookmarks-label' ).innerHTML =
'Bookmarks [<a href="/w/index.php?title=Special:MyPage/bookmarks.json&action=edit">edit</a>]';
'Bookmarks [<a href="/w/index.php?title=Special:MyPage/bookmarks.json&action=edit">edit</a>]';


document.getElementById( 'p-tb' ).after(
document.getElementById( 'p-bookmarks' )
);
for ( const bookmark of bookmarks ) {
for ( const bookmark of bookmarks ) {
mw.util.addPortletLink(
mw.util.addPortletLink(

Revision as of 21:38, 31 May 2024

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>]';

		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,
			);
		}
	} );