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.
// <nowiki>
//////////////////////////////////////////
// Tabs by Korath
// returns <li><a href="url">name</a></li>
//////////////////////////////////////////
/**** Add tab as menu ****/
/**** The CSS for this to work is on the talk page. ****/

function addlimenu(tabs, name, id)
{
    var na = document.createElement('a');
    na.href = '';
    var mn = document.createElement('ul');
    na.appendChild(document.createTextNode(name));
    var li = document.createElement('li');
    if(id) li.id = id;
    li.className = 'tabmenu';
    li.appendChild(na);
    li.appendChild(mn);
    tabs.appendChild(li);
    return li;
}

/**** Add generic tab ****/

function addlilink(tabs, url, name, id){
    var na = document.createElement('a');
    na.href = url;
    na.appendChild(document.createTextNode(name));
    var li = document.createElement('li');
    li.id = id;
    li.appendChild(na);
    tabs.appendChild(li);
    return li;
}


//////////////////////////////////////////
//
// Init everything
//
//////////////////////////////////////////

/**** Generic custom talk message ****/
function autoMessage(msgtext, summary, saveopt, top)
{
    var txt = document.editform.wpTextbox1;
    document.editform.wpSummary.value = summary;
    if(txt.value.length > 0) txt.value += '\n';

    if (top == 'true')
    {
        txt.value = msgtext + txt.value;
    }
    else 
    {
        txt.value += msgtext;
    }

    if(saveopt == 'save')
    {
        document.editform.submit();
    }
    else if(saveopt == 'preview')
    {
        document.editform.wpPreview.click();
    }
    else if(saveopt == 'diff')
    {
        document.editform.wpDiff.click();
    }
}

function autoWikiProjectTemplateOnTalkPage()
{
    if (document.title.indexOf('Editing ') == 0)
    {
      var action = '';
      var target = '';
      if (location.search)
      {
        var l = location.search.substring(1).split('&');
        for (var i = 0; i < l.length; ++i)
        {
          var eq = l[i].indexOf('=');
          var name = l[i].substring(0, eq);
          if (name == 'fakeaction')
          {
            action = l[i].substring(eq + 1);
          }
          else if (name == 'faketarget')
          {
            target = unescape(l[i].substring(eq + 1)).replace(/_/g, ' ');
          }
        } // end for
      } // end if "location.search"
      
      if (action == 'addtemplatetotop')
      {
        autoMessage("{{"+"WikiProject Oklahoma}}\n", "Add to [[Wikipedia:WikiProject Oklahoma]]", "preview", "true");
      }
      else if (action == 'addtorelatedchanges')
      {
        autoMessage("* [[" + target + "]]\n", "Add " + target + " to recent changes list", "preview", "false");        
      } // end if "action"
    } // end if "Editing"
}

function wikiProjectTemplateOnTalkPage()
{
  // TODO: THIS WILL NOT WORK FOR ALL LANGUAGES!
  var pagename = document.title.replace(" - Wikipedia, the free encyclopedia", "");
  var target   = pagename;

  window.open('/w/index.php?title=Talk:' + pagename + '&action=edit&fakeaction=addtemplatetotop&faketarget=' + target, pagename + ' add template', 'status,toolbar,location,menubar,directories,resizeable,scrollbars');

http://en.wikipedia.org/w/index.php?title=Wikipedia:WikiProject_Oklahoma/Oklahoma_recent_changes&action=edit

  window.open('/w/index.php?title=Wikipedia:WikiProject_Oklahoma/Oklahoma_recent_changes' + '&action=edit&fakeaction=addtorelatedchanges&faketarget=' + pagename,
              pagename + ' add to recent changes',
              'status,toolbar,location,menubar,directories,resizeable,scrollbars');

}

function asdf()
{
  
  // these will be replaced...
  var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
  addlilink(tabs, 'javascript:wikiProjectTemplateOnTalkPage()', '{{WP:OK}}', '');

//  addlilink(tabs, 'http://www.ashlux.com/', 'Ashlux.com', 'ashlux.com');
//  addlimenu(tabs, 'bcrat', 'bfunc');
//  var bfunc = document.getElementById('bfunc').getElementsByTagName('ul')[0];
//  addlilink(bfunc, 'asdf', 'make sysop', 'sysop');
}

$(asdf);

if (window.addEventListener) window.addEventListener('load', autoWikiProjectTemplateOnTalkPage, false);
else if (window.attachEvent) window.attachEvent('onload', autoWikiProjectTemplateOnTalkPage);
// </nowiki>