تفصیل کے لیے کھولیں کے بٹن پر کلک کریں یاددہانی: محفوظ کرنے کے بعد تازہ ترین تبدیلیوں کو دیکھنے کے لیے آپ کو اپنے براؤزر کا کیش صاف کرنا ہوگا۔

  • فائرفاکس/ سفاری: جب Reload پر کلک کریں تو Shift دبا کر رکھیں، یا Ctrl-F5 یا Ctrl-R دبائیں (Mac پر R- )
  • گوگل کروم: Ctrl-Shift-R دبائیں (Mac پر Shift-R-⌘)
  • انٹرنیٹ ایکسپلورر: جب Refresh پر کلک کریں تو Ctrl یا Ctrl-F5 دبائیں
  • اوپیرا: Tools → Preferences میں جائیں اور کیش صاف کریں

$(function() {
    function i18n(name) {
        var msg = {
            mark: ['بطور خواندہ نشان زد کریں', 'Mark as read'],
            unmark: ['بطور غیر خواندہ نشان زد کریں', 'Mark as unread'],
            close: ['نظر ثانی چھپائیں', 'Hide revision'],
            markFlow: ['موضوع بطور خواندہ نشان زد کریں', 'Mark flow as read'],
            markCat: ['زمرہ بطور خواندہ نشان زد کریں', 'Mark categorization as read'],
            manymarked: ['سطریں نشان زد', 'lines marked'],
            goldbutton: ['کھولیں اون اس صفحے کی تمام نظرثانیوں کو نشان زد کریں', 'Open and mark all this page revisions'],
            jsonlost: ['ترتیب فائل نہیں مل سکی', 'Configuration file not found'],
            hideAll: ['تمام خواندہ چھپائیں', 'Hide all read'],
            showAll: ['تمام پوشیدہ دکھائیں', 'Show all hidden'],
            loga: ['توجہ فرمایے: רשימת המעקב כוללת רשומת יומן שלא נקראה. הדף הוא ',
                'Pay attention: the watchlist includes unread log entry. Page name: '
            ],
            logb: [', הפעולה שנעשתה היא: ', ', log action: '],
            logc: ['(تفصیلات)', '(details)'],
            logd: ['אם ברצונכם לסמן אותה כנקראה, בדקו כי אין עריכות אחרות של הדף הזה שלא נקראו,' +
                ' כי גם הן יסומנו. לאחר מכן לחצו ', 'If you want to mark it as read, check that there are' +
                ' no other unwatched revisions of this page, because they will be marked too. Then click '
            ],
            loge: ['یہاں', 'here'],
            clear: ['صفاف', 'clear'],
            help: ['تفصیلات کے لیے دیکھیے معاونت:انتظام زیر نظر فہرست', '']
		};
		return msg[name][lang || 0];
	}

	function button(msg, icon) {
		return $('<a>', {
				text: '\u200f',
				title: i18n(msg),
				href: '#nw'
			})
			.addClass(icon + ' WLM-icon');
	}

	function seen(obj) {
		obj.filter(function() {
				return $(this)
					.closest('.mw-changeslist-line-watched')
					.filter(notcat)
					.find('a[href*="diff"]')
					.filter(notme)
					.filter(function() {
						return $(this)
							.closest('.mw-enhanced-rc-nested')
							.length <= 0;
					})
					.length > 0;
			})
			.before(button('mark', 'mark-edits')
				.click(function() {
					if (config.hidemarked.edit)
						$('.yellowedit')
						.hide();
					var $this = $(this),
						diff = /diff=([0-9]+)/.exec($this.parent()
							.find('a[href*="diff"]')
							.filter(notme)
							.prop('href'))[1],
						name = $this.parent()
						.find('.mw-changeslist-title')
						.text(),
						all = $('.mw-changeslist-line-watched .mw-changeslist-title')
						.filter(function() {
							var thediff = /.*diff=([0-9]+).*oldid.*/.exec($(this)
								.closest('.mw-changeslist-line-watched')
								.find('a[href*="diff"]')
								.filter(notme)
								.prop('href'));
							return thediff && $(this)
								.text() == name && thediff[1] <= diff;
						})
						.closest('.mw-changeslist-line-watched'),
						allboth = $('.mw-changeslist-line-watched .mw-changeslist-title')
						.filter(function() {
							return $(this)
								.text() == name;
						})
						.closest('.mw-changeslist-line-watched');
					new mw.Api()
						.postWithToken('csrf', {
							action: 'setnotificationtimestamp',
							titles: name,
							newerthanrevid: diff
						})
						.done(function() {
							if (all.length > 1)
								$this.closest('table, li')
								.append($('<span>')
									.text(' ' + all.length + ' ' + i18n('manymarked') + ' ')
									.css({
										backgroundColor: 'red'
									}));
							all.removeClass('mw-changeslist-line-watched blueedit')
								.addClass('mw-changeslist-line-not-watched yellowedit')
								.show()
								.find('.mark-edits')
								.remove();
							allboth.find('.gold-button')
								.remove();
							unseen(all.find('span.mw-title'));
							if (! config.hidemarked.wait)
								all.hide();
						});
				}));
	}

	function unseen(obj) {
		obj.filter(function() {
				return $(this)
					.closest('table, li')
					.filter(notcat)
					.find('a[href*="oldid"]')
					.length > 0;
			})
			.before(button('unmark', 'unmark-edits')
				.click(function() {
					var $this = $(this),
						diffcond = $this
						.closest('.mw-changeslist-line-not-watched')
						.find('abbr.newpage')
						.length > 0,
						oldrev = diffcond ? 0 : /oldid=([0-9]+)/.exec($this
							.parent()
							.find('a[href*="oldid"]')
							.filter(notme)
							.prop('href'))[1],
						diff = diffcond ? 0 : /diff=([0-9]+)/.exec($this
							.parent()
							.find('a[href*="diff"]')
							.filter(notme)
							.prop('href'))[1],
						name = $this
						.next()
						.text(),
						all = $('.mw-changeslist-line-not-watched .mw-changeslist-title')
						.filter(function() {
							var thediff = /.*diff=([0-9]+).*oldid.*/.exec($(this)
								.closest('.mw-changeslist-line-not-watched')
								.find('a[href*="diff"]')
								.filter(notme)
								.prop('href'));
							return thediff && $(this)
								.text() == name && thediff[1] >= diff;
						})
						.closest('.mw-changeslist-line-not-watched');
					new mw.Api()
						.postWithToken('csrf', {
							action: 'setnotificationtimestamp',
							titles: name,
							newerthanrevid: oldrev
						})
						.done(function() {
							if (all.length > 1)
								$this.closest('table, li')
								.append($('<span>')
									.text(' ' + all.length + ' ' + i18n('manymarked') + ' ')
								);
							all.removeClass('mw-changeslist-line-not-watched yellowedit')
								.addClass('mw-changeslist-line-watched blueedit')
								.show()
								.find('.unmark-edits')
								.remove();
							seen(all.find('span.mw-title'));
						});
				}));
	}

	function flowseen() {
		$('.mw-changeslist-line-watched a.mw-title')
			.parent()
			.prepend(button('markFlow', 'mark-all-flow-edits')
				.click(function() {
					var $this = $(this),
						topic = /title=[^:]*:(.+)&/.exec($this.parent()
							.find('a[href*="fromnotif"]')
							.prop('href')),
						page = $this
						.closest('.mw-changeslist-line-watched')
						.find('a.mw-title')
						.prop('title'),
						titles = topic ? page + '|موضوع:' + topic[1] : page;
					new mw.Api()
						.postWithToken('csrf', {
							action: 'setnotificationtimestamp',
							titles: titles,
						})
						.done(function() {
							if (config.hidemarked.flow)
								$this.closest('.mw-changeslist-line-watched')
								.hide();
							$this.closest('.mw-changeslist-line-watched')
								.removeClass('mw-changeslist-line-watched blueedit')
								.addClass('mw-changeslist-line-not-watched yellowedit');
							$this.remove();
						});
				}));
	}

	function categoryseen() {
		$('.mw-changeslist-line-watched span.mw-title')
			.filter(function() {
				return ($(this)
						.closest('.mw-changeslist-line-watched')
						.find('a[href*="diff"]')
						.length <= 0 && $(this)
						.closest('.mw-changeslist-line-watched')
						.find('abbr.newpage')
						.length <= 0) ||
					$(this)
					.find('a.mw-changeslist-title')
					.parent()
					.next()
					.text() == '. .';
			})
			.before(button('markCat', 'mark-cat-edits')
				.click(function() {
					var $this = $(this),
						page = $this.parent()
						.find('a.mw-changeslist-title')
						.prop('title');
					new mw.Api()
						.postWithToken('csrf', {
							action: 'setnotificationtimestamp',
							titles: page,
						})
						.done(function() {
							if (config.hidemarked.categorization)
								$this.closest('.mw-changeslist-line-watched')
								.hide();
							$this.closest('.mw-changeslist-line-watched')
								.removeClass('mw-changeslist-line-watched blueedit')
								.addClass('mw-changeslist-line-not-watched yellowedit');
							$this.remove();
						});
				}));
	}

	function checklog() {
		new mw.Api()
			.get({
				action: 'query',
				format: 'json',
				list: 'watchlist',
				indexpageids: 1,
				wllimit: 500,
				wlprop: 'title|loginfo',
				wlshow: 'unread',
				wltype: 'log'
			})
			.done(function(date) {
				var firstname = date.query.watchlist;
				if (firstname.length > 0) {
					firstname = firstname[0];
					$('#hideAll')
						.after($('<div>', {
								id: 'logmessage'
							})
							.addClass('blueedit')
							.append($('<span>')
								.text(i18n('loga')))
							.append($('<span>')
								.text(firstname.title)
								.css({
									fontWeight: 'bold',
								}))
							.append($('<span>')
								.text(i18n('logb') + firstname.logaction + ' '))
							.append($('<a>', {
								href: 'https://ur.wikipedia.org//w/api.php?action=query&format=rawfm&list=watchlist&' +
									'indexpageids=1&wllimit=500&wlprop=title%7Cloginfo&wlshow=unread&wltype=log',
								text: i18n('logc')
							}))
							.append($('<span>')
								.text('. ' + i18n('logd') + ' '))
							.append($('<a>')
								.text(i18n('loge'))
								.click(function() {
									new mw.Api()
										.postWithToken('csrf', {
											action: 'setnotificationtimestamp',
											titles: firstname.title
										})
										.done(function() {
											$('#logmessage')
												.remove();
											var all = $('.mw-changeslist-line-watched a.mw-changeslist-title')
												.filter(function() {
													return $(this)
														.prop('title') == firstname.title;
												})
												.closest('.mw-changeslist-line-watched');
											all.removeClass('mw-changeslist-line-watched blueedit')
												.addClass('mw-changeslist-line-not-watched yellowedit')
												.show()
												.find('.unmark-edits')
												.remove();
											if (config.hidemarked.edit)
												$('.yellowedit')
												.hide();
											seen(all.find('span.mw-title'));
											if (all.length > 0)
												$('#hideAll')
												.after($('<span>')
													.text(' ' + all.length + ' ' + i18n('manymarked') + ' ')
												)
												.addClass('yellowedit');
											checklog();
										});
								}))
							.append($('<span>')
								.text('.')
							));
				}
			});
	}

	function goldbutton() {
		$('.close-edit')
			.filter(function() {
				return $(this)
					.closest('.mw-changeslist-line-watched')
					.filter(notcat)
					.find('a[href*="diff"]')
					.filter(notme)
					.filter(function() {
						return $(this)
							.closest('.mw-enhanced-rc-nested')
							.length <= 0;
					})
					.length > 0 &&
					$(this)
					.closest('.mw-changeslist-line-watched')
					.find('a.mw-title')
					.length <= 0;
			})
			.each(function() {
				var name = $(this)
					.closest('.mw-changeslist-line-watched')
					.find('.mw-changeslist-title')
					.text(),
					checked = $('.mw-changeslist-title')
					.filter(function() {
						return $(this)
							.text() == name;
					})
					.closest('.mw-changeslist-line-watched'),
					nonew = checked
					.find('abbr.newpage')
					.length <= 0,
					min = Infinity;
				checked
					.find('a[href*="oldid"]')
					.filter(notme)
					.filter(function() {
						return ($(this)
								.text() == messages.diff || $(this)
								.text() == messages.last) &&
							($(this)
								.closest('.mw-enhanced-rc-nested')
								.closest('.mw-enhanced-watched')
								.length > 0 ||
								$(this)
								.closest('.mw-enhanced-rc-nested')
								.length <= 0);
					})
					.each(function() {
						var old = /oldid=([0-9]+)/.exec($(this)
							.prop('href'));
						min = old ? Math.min(min, old[1]) : min;
					});
				if (min > 0 && min != Infinity && nonew) {
					$(this)
						.after($('<a>', {
								text: '\u200f',
								title: i18n('goldbutton'),
								target: '_blank',
								href: 'https://ur.wikipedia.org/w/index.php?title=' + name + '&diff=cur&oldid=' + min
							})
							.addClass('gold-button WLM-icon')
							.click(function() {
								if (config.hidemarked.edit)
									$('.yellowedit')
									.hide();
								var all = $('.mw-changeslist-line-watched .mw-changeslist-title')
									.filter(function() {
										return $(this)
											.text() == name;
									})
									.closest('.mw-changeslist-line-watched');
								if (all.length > 1)
									$(this)
									.closest('table, li')
									.append($('<span>')
										.text(' ' + all.length + ' ' + i18n('manymarked') + ' ')
										.css({
											backgroundColor: 'red'
										}));
								all.removeClass('mw-changeslist-line-watched blueedit')
									.addClass('mw-changeslist-line-not-watched yellowedit')
									.show()
									.find('.mark-edits, .gold-button')
									.remove();
								unseen(all.find('span.mw-title'));
							}));
				}
			});
	}

	function closeedit() {
		var btn = button('close', 'close-edit')
			.click(function() {
				$(this)
					.closest('.mw-changeslist-line-not-watched, .mw-changeslist-line-watched')
					.hide();
			});
		$('li span.mw-changeslist-date')
			.parent()
			.prepend(btn);
		$('td.mw-enhanced-rc')
			.parent()
			.filter(function() {
				return $(this)
					.find('td.mw-enhanced-rc-nested')
					.length <= 0;
			})
			.prepend($('<td>')
				.html(btn)
				.css({
					whiteSpace: 'nowrap'
				}));
		$('td.mw-enhanced-rc')
			.parent()
			.find('td.mw-enhanced-rc-nested')
			.prev()
			.before($('<td>'));
	}

	function notme() {
		return !$(this)
			.hasClass('WLM-icon');
	}

	function notcat() {
		return $(this)
			.find('a.mw-changeslist-title')
			.parent()
			.next()
			.text() != '. .';
	}

	function hider(state) {
		if (config.edit[state])
			$('.mw-changeslist-line-not-watched')
			.filter(function() {
				return $(this)
					.find('abbr.wikibase-edit')
					.length <= 0;
			})
			.hide();
		if (config.log[state])
			$('[class*="mw-changeslist-log"]')
			.hide();
		if (config.wikidata[state])
			$('abbr.wikibase-edit')
			.closest('.mw-changeslist-line-watched, .mw-changeslist-line-not-watched')
			.hide();
		$('#logmessage')
			.hide();
	}

	function unhider() {
		$('.mw-changeslist-line-watched')
			.show();
		if (config.edit.show)
			$('.mw-changeslist-line-not-watched')
			.filter(function() {
				return $(this)
					.find('abbr.wikibase-edit')
					.length <= 0;
			})
			.show();
		if (config.log.show)
			$('[class*="mw-changeslist-log"]')
			.show();
		if (config.wikidata.show)
			$('abbr.wikibase-edit')
			.closest('.mw-changeslist-line-not-watched')
			.show();
		$('#logmessage')
			.show();
	}

	function main() {
		seen($('.mw-changeslist-line-watched span.mw-title'));
		unseen($('.mw-changeslist-line-not-watched span.mw-title'));
		flowseen();
		categoryseen();
		closeedit();
		goldbutton();
		hider('starthidden');
	}

	function demo() {
		$('.mark-edits')
			.click(function() {
				var id = $(this)
					.parent()
					.prop('id');
				$(this)
					.closest('table')
					.find('.mark-edits')
					.filter(function() {
						return $(this)
							.parent()
							.prop('id') <= id;
					})
					.removeClass('mark-edits')
					.addClass('unmark-edits')
					.parent()
					.removeClass('blueedit')
					.addClass('yellowedit');
				demo();
			});
		$('.unmark-edits')
			.click(function() {
				var id = $(this)
					.parent()
					.prop('id');
				$(this)
					.closest('table')
					.find('.unmark-edits')
					.filter(function() {
						return $(this)
							.parent()
							.prop('id') >= id;
					})
					.removeClass('unmark-edits')
					.addClass('mark-edits')
					.parent()
					.removeClass('yellowedit')
					.addClass('blueedit');
				demo();
			});
	}
	
	if (mw.config.get('wgCanonicalSpecialPageName') == 'Watchlist') {
		var langcode = mw.user.options.get('language'),
			lang = langcode == 'ur' ? 0 : 1,
			config, messages;
		var extendwatchlist = false;
		mw.loader.using('mediawiki.user')
			.then(function() {
				extendwatchlist = mw.user.options.get('extendwatchlist');
				if (extendwatchlist == 1) {
					$('.mw-body-content')
						.addClass(typeof window.orientation == 'undefined' ? 'WLM-desktop' : 'WLM-mobile');
					importStylesheet('mediawiki:Gadget-WLM.css');
					importStylesheet('user:' + mw.config.get('wgUserName') + '/WLM.css');
					importStylesheet('user:' + mw.config.get('wgUserName') + '/common.css');
					mw.loader.using(['mediawiki.api', 'mediawiki.jqueryMsg'])
						.then(function() {
							new mw.Api()
								.getMessages(['diff', 'last'], {
									amlang: langcode
								})
								.then(function(result) {
									messages = result;
								});
						})
						.then(function() {
							$.get(mw.util.wikiScript(), {
									title: 'mediawiki:Gadget-WLM.json',
									action: 'raw'
								})
								.done(function(data) {
									config = JSON.parse(data);
									$.get(mw.util.wikiScript(), {
											title: 'user:' + mw.config.get('wgUserName') + '/WLM.json',
											action: 'raw'
										})
										.done(function(data1) {
											config = JSON.parse(data1);
										})
										.always(main);
								})
								.fail(function() {
									console.log('ERR: ' + i18n('jsonlost'));
								});
						});
					mw.loader.using('mediawiki.util')
						.done(function() {
							$('#mw-watchlist-form')
								.after($('<input>', {
										id: 'hideAll',
										type: 'submit',
										title: i18n('help')
									})
									.click(function() {
										hider('hide');
									}))
								.after($('<span>', {
										text: 'place',
										id: 'placeholder'
									})
									.css({
										visibility: 'hidden',
									}))
								.after($('<input>', {
										id: 'showAll',
										type: 'submit',
										title: i18n('help')
									})
									.click(unhider))
								.after($('<div>', {
										text: 'place',
										id: 'placeline'
									})
									.css({
										visibility: 'hidden',
										fontSize: '50%'
									}));
							$('#hideAll')
								.attr('value', i18n('hideAll'));
							$('#showAll')
								.attr('value', i18n('showAll'));
							checklog();
						});
				}
			});
	} else if (mw.config.get('wgPageName') == 'معاونت:WLM') {
		$('.prescell')
			.attr('align', 'center')
			.each(function() {
				$(this)
					.html($('<a>')
						.addClass($(this)
							.attr('class')));
				$(this)
					.removeClass('mark-edits unmark-edits');
			});
		$('#clear')
			.prepend($('<input>', {
					id: 'clearbutton',
					type: 'submit'
				})
				.click(function() {
					$('.blueedit, .yellowedit')
						.removeClass('blueedit yellowedit');
				}));
		$('#clearbutton')
			.attr('value', i18n('clear'));
		demo();
	}
})();