Jump to content

User:Lifebaka/welcome.js

From Wikipedia, the free encyclopedia
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.
//Adds a tab titled "welcome" to the top of user talk pages when editing
//Clicking on "welcome" tab adds my welcome message to the page
//and "welcome!" to the edit summary
//written by [[User:Lifebaka]], modified from [[Wikipedia:WikiProject User scripts/Scripts/CloseAFD.js]] written by [[User:Johnleemk]]
//to use this code, simply add importScript('User:Lifebaka/welcome.js'); to your monobook.js or vector.js page
//feel free to copy and change this code as necessary (using your own copy, please); any modifications I have made from the source are public domain

function welcome_function()
{
  var f = document.editform, t = f.wpTextbox1;
  t.value += "{{subst:" + "User:Lifebaka/Welcome" + "}}";
  f.wpSummary.value += "welcome!";
}
 
function add_welcome_tab()
{
  // Only add for pages with the right string somewhere in the title
  if ((document.title.indexOf("Editing User talk:") != -1) && (document.title.indexOf("(new section)") == -1))
    {
      mw.util.addPortletLink('p-cactions', 'javascript:welcome_function()', "Welcome this user!");
    }
}
 
$(add_welcome_tab);