Jump to content

User:FreddoR/menu.js

From Wikipedia, the free encyclopedia
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
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.
/*
ATT GÖRA:
 - Länk i Tool-menyn för 'add/remove this page to shortcut'



*/




// Set each new link's text and url
$('.myLinks1').text('Policies').attr('href', 'http://en.wikipedia.org/wiki/Wikipedia:List_of_policies');
$('.myLinks2').text('Guidelines').attr('href', 'http://en.wikipedia.org/wiki/Wikipedia:List_of_guidelines');
$('.myLinks3').text('Main Style').attr('href', 'http://en.wikipedia.org/wiki/Wikipedia:Manual_of_Style/Contents');
$('.myLinks4').text('Wiki Markup').attr('href', 'http://en.wikipedia.org/wiki/Help:Wiki_markup');
$('.myLinks5').text('Template Tagging').attr('href', 'https://en.wikipedia.org/wiki/Wikipedia:Template_messages');
$('.myLinks6').text('Cleanup Tags').attr('href', 'https://en.wikipedia.org/wiki/Wikipedia:Template_messages/Cleanup#General_cleanup');
$('.myLinks7').text('List of InfoBoxes').attr('href', 'https://en.wikipedia.org/wiki/Wikipedia:List_of_infoboxes');

$('#p-interaction').clone(true).insertAfter($('#p-interaction')).addClass('mylinks').removeAttr('id').find('h3').text('Shortcuts');
$('.mylinks li').remove();

$('.mylinks ul').append('<li><a href="/wiki/Wikipedia:List_of_guidelines">Guidelines</a></li>');
$('.mylinks ul').append('<li><a href="/wiki/Wikipedia:Manual_of_Style/Contents">Style Manual</a></li>');
/*
$('.mylinks .pBody ul').append('<li><a class="myLinks3"></a></li>');
$('.mylinks .pBody ul').append('<li><a class="myLinks4"></a></li>');
$('.mylinks .pBody ul').append('<li><a class="myLinks5"></a></li>');
$('.mylinks .pBody ul').append('<li><a class="myLinks6"></a></li>');
$('.mylinks .pBody ul').append('<li><a class="myLinks7"></a></li>');
*/

var ptLinksToAdd = [
        {
                label: "Watchlist",
                title: "My watchlisted pages",
                url: "/wiki/Special:Watchlist",
                index: 5
        },
        {
                label: "AfD",
                url: "/wiki/Wikipedia:Articles_for_Deletion",
                index: 6
        }
 ];
 
 
/* 
var ptList2 = document.getElementsByClassName("myLinks").getElementsByTagName("ul")[0]; 

for (var i = 0; i < ptLinksToAdd.length; i++) {
	var newListItem = document.createElement("li");
	var newLink = document.createElement("a");
	newLink.setAttribute("href", ptLinksToAdd[i].url);
	if (ptLinksToAdd[i].hasOwnProperty("title")) {
		newLink.setAttribute("title", ptLinksToAdd[i].title);
	}
	newLink.appendChild(document.createTextNode(ptLinksToAdd[i].label));
	newListItem.appendChild(newLink);
	
	//if (ptLinksToAdd[i].hasOwnProperty("index")) {
	//	ptList2.insertBefore(newListItem, ptList2.childNodes[ptLinksToAdd[i].index]);
	//} else {
		ptList2.appendChild(newListItem);
	//}
}
*/


var ptList = document.getElementById("p-personal").getElementsByTagName("ul")[0];

for (var i = 0; i < ptLinksToAdd.length; i++) {
	var newListItem = document.createElement("li");
	var newLink = document.createElement("a");
	newLink.setAttribute("href", ptLinksToAdd[i].url);
	if (ptLinksToAdd[i].hasOwnProperty("title")) {
		newLink.setAttribute("title", ptLinksToAdd[i].title);
	}
	newLink.appendChild(document.createTextNode(ptLinksToAdd[i].label));
	newListItem.appendChild(newLink);
	
	if (ptLinksToAdd[i].hasOwnProperty("index")) {
		ptList.insertBefore(newListItem, ptList.childNodes[ptLinksToAdd[i].index]);
	} else {
		ptList.appendChild(newListItem);
	}
}