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.
if( mw.config.get('wgPageName') === 'Special:Watchlist' ) {
	var button = '<input type="submit" value="Select latest unread" id="watchlist-select-ts" style="margin-top:1em;"></input>';
	$('#mw-watchlist-resetbutton').after(button);
	$('#watchlist-select-ts').click(function() { createSelectLinks(); } );
}

function createSelectLinks() {
	for(var i = 0; i < $('.mw-changeslist-line').length; i++) {
	    $('.mw-changeslist-line')[i].id = 'mw-changeslist-line';
		$('#mw-changeslist-line').prepend('<a class="changeslist-select-ts" data-ts="' + $('.mw-changeslist-line')[i].dataset.mwTs + '">Sel</span> ').click( function(event) { setTS(event.originalEvent.target.dataset.ts);} );
		$('.mw-changeslist-line')[i].id = '';
	}
}

function setTS (ts) {
	$.ajax( {
    	url: mw.util.wikiScript('api'),
    	type: 'post',
    	dataType: 'json',
    	data: {
        	action: 'setnotificationtimestamp',
        	format: 'json',
			entirewatchlist: 1,
        	timestamp: ts,
        	token: mw.user.tokens.get('csrfToken'),
    	}
	});
	$('.changeslist-select-ts').replaceWith();
}