صارف:Obaid Raza/RLRL SR Utility.js
آپ کی توجہ درکار ہے۔ اس صفحہ میں جو اسکرپٹ شامل ہیں، وہ صفحہ لوڈ ہونے پر ہر دفعہ چلیں گی۔ لہذا خراب، غلط اور نامناسب کوڈ یا اسکرپٹ یہاں درج نہ کریں۔ اس سے آپ کے کھاتے کو بھی خطرہ لاحق ہو سکتا ہے۔ |
یاددہانی: محفوظ کرنے کے بعد تازہ ترین تبدیلیوں کو دیکھنے کے لیے آپ کو اپنے براؤزر کا کیش صاف کرنا ہوگا۔
- فائرفاکس/ سفاری: جب Reload پر کلک کریں تو Shift دبا کر رکھیں، یا Ctrl-F5 یا Ctrl-R دبائیں (Mac پر R- )
- گوگل کروم: Ctrl-Shift-R دبائیں (Mac پر Shift-R-⌘)
- انٹرنیٹ ایکسپلورر: جب Refresh پر کلک کریں تو Ctrl یا Ctrl-F5 دبائیں
- اوپیرا: Tools → Preferences میں جائیں اور کیش صاف کریں
اس اسکرپٹ کی دستاویزی تفصیلات صارف:Obaid Raza/RLRL SR Utility پر درج کی جا سکتی ہیں۔ |
// Create some search-and-replace tools - this uses a slightly modified version
// of [[en:User:Gerbrant/edit/regexReplace.js]])
mw.loader.load( 'https://ur.wikipedia.org/w/index.php?title=en:User:Topbanana/regexReplace.js&action=raw&ctype=text/javascript');
function RLRL_SR_Utility()
{
strAdvert = ' - [[w:en:WP:RLR|You can help!]]';
// Check if we are editing
if ( document.getElementById("editform") )
{
// Check for and extract parameters
parSearch = mw.util.getParamValue( 'RLRLS' );
parReplace = mw.util.getParamValue( 'RLRLR' );
parRedirect = mw.util.getParamValue( 'RLRLRD' );
// First check if we are being asked to create a redirect
if( parRedirect )
{
// Check we have no other parameters
if( parSearch || parReplace )
return;
// Check the edit box is empty
if( document.forms.editform.wpTextbox1.value.length > 0 )
return;
// Correct the parameters provided
parRedirect = unescape( decodeURIComponent( parRedirect.replace( /_/g, " " ) ) );
// Okay, populate the edit box and summary
document.forms.editform.wpTextbox1.value = '#REDIRECT [[' + parRedirect+ ']]';
document.forms.editform.wpSummary.value =
'Link repair: Redirecting page to ' + parRedirect + strAdvert;
document.forms.editform.wpWatchthis.checked = false;
return;
}
// Okay, not a redirect. Check if we are being asked to search-and-replace
// If we've not got a useful set of parameters, give up
if( !parSearch || !parReplace )
return;
// Correct the parameters provided
parSearch = unescape( decodeURIComponent( parSearch.replace( /_/g, " " ) ) );
parReplace = unescape( decodeURIComponent( parReplace.replace( /_/g, " " ) ) );
// Check for Template namespace prefix
if( parSearch.indexOf( "Template:" ) == 0 &&
parReplace.indexOf( "Template:" ) == 0 )
{
parSearch = parSearch.slice( 9 );
parReplace = parReplace.slice( 9 );
}
// Escape any characters with special meanings in regular expressions
parRegex = parSearch.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
// Specifically ignore the case of the first letter
parRegex = '[' + parRegex.substring(0, 1).toUpperCase() +
parRegex.substring(0, 1).toLowerCase() + ']' +
parRegex.substring(1);
// Find and manipulate the search and replace controls
createRegexControls();
document.getElementById('tbRegex_SearchCaseSensitive').checked = true;
document.getElementById('tbRegex_SearchTextBox').value = parRegex;
document.getElementById('tbRegex_FindButton').click();
document.getElementById('tbRegex_ReplaceTextBox').value = parReplace;
// Populate the edit summary
document.forms.editform.wpSummary.value =
'Link repair: ' + parSearch + ' -> ' + parReplace + strAdvert;
document.forms.editform.wpMinoredit.checked = true;
}
// Check if we are editing
if ( document.getElementById("movepage") )
{
// Check for and extract parameters
parNewNS = mw.util.getParamValue( 'RLRLMNS' );
parNewTitle = mw.util.getParamValue( 'RLRLMNT' );
// If we've not got a useful set of parameters, give up
if( !parNewNS || !parNewTitle )
return;
// Correct the parameters provided
parNewTitle = unescape( decodeURIComponent( parNewTitle.replace( /_/g, " " ) ) );
document.getElementById('wpNewTitleNs').value = parNewNS;
document.getElementById('wpNewTitleMain').value = parNewTitle;
// Populate the edit summary
document.getElementById('wpReason').value = strAdvert;
}
};
$( RLRL_SR_Utility );