User:Technical 13/vector.js

/* Test for adding links in diffs */ if($('table.diff').length != 0){ if($('table.diff').text.match(/([\d\w\s]*?)\.(jpg|png|jpeg|bmp)/gi) != null){ Array.prototype.unique = function(a){ return function{ return this.filter(a) } }(function(a,b,c){ return c.indexOf(a,b+1) < 0 }); var linkedHTML = ''; var linkedText = $('table.diff').text.match(/([\d\w\s:]*?)\.(jpg|png|jpeg|bmp)/gi); console.log('linkedText: %s', linkedText); var linkDestination = $('table.diff').text.match(/([\d\w\s]*?)\.(jpg|png|jpeg|bmp)/gi); console.log('linkDestination: %s', linkDestination); linkedText = linkedText.unique; console.log('unique linkedText: %s', linkedText); linkDestination= linkDestination.unique; console.log('unique linkDestination: %s', linkDestination); for(var i=0; i<linkedText.length; i++){ linkedText[i] = linkedText[i].trim; console.log('linkedText[%d]: %s', i, linkedText[i]); linkedHTML = $('table.diff').html.closest(':contains(linkDestination[i].substr(0, (linkDestination[i].length - 4)))'); console.log('linkedHTML: %s', linkedHTML); linkDestination[i] = linkDestination[i].trim; console.log('linkDestination[%d]: %s', i, linkDestination[i]); //			$('table.diff').html($('table.diff').html.replace(linkedHTML[i], '' + linkedHTML[i] + '')); console.log('.replace: %s ::with: %s', linkedHTML[i], linkDestination[i], linkedText[i], linkedHTML[i]); }	} }

/* QL *//* Testing for Template:Quest list and MediaWiki:Template-Quest list.js */ importScript( 'MediaWiki:Template-Quest list.js' );

/* Testing for User:Technical_13/Scripts/Gadget-nsShortener.js */ importScript('User:Technical_13/Scripts/Gadget-nsShortener.js');//User:Technical_13/Scripts/Gadget-nsShortener

/* Special:DoubleRedirects project */ if(mw.config.get("wgCanonicalSpecialPageName") === "DoubleRedirects"){ if(mw.config.get('wgUserGroups').indexOf('steward') !== -1 || mw.config.get('wgUserGroups').indexOf('bot') !== -1){ //		if(mw.config.get('wgUserGroups').indexOf('bot') === -1){ function demoteSelf{ $.ajax({					url: mw.config.get('wgScriptPath') + '/api.php?action=userrights&remove=bot&token=' + rightsToken + '&user=' + encodedUsername + '&reason=' + encodeURIComponent("Done with bot bit for processing Special:DoubleRedirects auto-magically"),					type: 'POST',					success: function{						alert("You have removed yourself from the bot group."); console.warn("You have removed yourself from the bot group.");					},					fail: function{						alert("Something went wrong and you have NOT removed yourself from the bot group!"); console.error("Something went wrong and you have NOT removed yourself from the bot group!");					}				}); }			function fixDoublesRedirects{ var succeeded = false; var editToken = mw.user.tokens.get("editToken").replace(/\+\\$/g, '%2B%5C'); var nextLink = $(".mw-nextlink").html; var limit = document.location.href.slice(document.location.href.search("limit=")+6, document.location.href.search("&")); var editSummary = encodeURIComponent("Fixing Special:DoubleRedirects using Double redirect fixer"); if(nextLink !== null && (!$.isNumeric(limit) || limit === "")){ limit = document.location.href.slice(document.location.href.search("limit=")+6); }				else if(nextLink !== null && limit !== 1000){ setTimeout(function{location = '?limit=1000'},1); }				$("ol.special").find("li").each(function{					var doubleRedirect = $(this).find("a:first").attr("title");					var redirectTarget = $(this).find("a:last").attr("title");					var writeRedirect = encodeURIComponent("#REDIRECT " + redirectTarget + "\n\n");					$.ajax({ url: mw.config.get('wgScriptPath') + '/api.php?action=edit&title=' + encodeURIComponent(doubleRedirect) + '&summary=' + editSummary + '&minor=1&recreate=1&bot=1&text=' + writeRedirect + '&token=' + editToken, type: 'POST', success: function { succeeded = true; }					});				});				demoteSelf; }			function promoteSelf{ var isBot = confirm("You must manually assign yourself into the bot group to run this script for now.\nCopy and paste URL is:\n\t\thttp://ddowiki.com/page/Special:UserRights/" + encodedUsername + "\nCustom reason to use is:\n\tAdding bot bit to process Special:DoubleRedirects auto-magically."); if (!isBot){ throw ''; } else { fixDoublesRedirects; } /*				$.ajax({					url:mw.config.get('wgScriptPath') + '/api.php?action=userrights&add=bot&token=' + rightsToken + '&user=' + encodedUsername + '&reason=' + encodeURIComponent("Adding bot bit to process Special:DoubleRedirects auto-magically"),					type: 'POST',					success: function {						alert("You have temporarily assigned yourself to the bot group."); console.warn("You have temporarily assigned yourself to the bot group.");						fixDoublesRedirects;					},					fail: function {						alert("You have NOT assigned yourself to the bot group!"); console.error("You have NOT assigned yourself to the bot group!");					}				}); }			var rightsToken = ""; var encodedUsername = encodeURIComponent(mw.config.get('wgUserName')); $.ajax({				url: mw.config.get('wgScriptPath') + '/api.php?action=query&format=json&list=users&ustoken=userrights&ususers=' + encodedUsername,				dataType: 'json',				success: function(getToken) {					rightsToken = getToken.query.users[0].userrightstoken.replace(/\+\\$/, '%2B\\'); console.info(rightsToken);					promoteSelf;				}			}); //		}	} }