User:Joelminer/common.js
Jump to navigation
Jump to search
In other languages: Deutsch • Français
Note: After saving, you may have to bypass your browser's cache to see the changes.
- Google Chrome / Microsoft Edge / Opera: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
function waitForElement(selector) {
return new Promise(function(resolve) {
if (document.querySelector(selector)) {
return resolve(document.querySelector(selector));
}
var observer = new MutationObserver(function(mutations) {
if (document.querySelector(selector)) {
observer.disconnect();
resolve(document.querySelector(selector));
}
});
observer.observe(document.documentElement, {
childList: true,
subtree: true
});
});
}
var promises = [
waitForElement("#wikigg-header"),
waitForElement("#mw-panel"),
waitForElement("#p-personal"),
waitForElement("#pt-logout"),
waitForElement(".vector-menu-content-list.menu")
];
Promise.all(promises).then(function(elements) {
// Get the mw-panel div and delete it
var mwPanel = document.getElementById('mw-panel');
mwPanel.style.display = 'none';
//liElement4 = document.querySelector('#p-themes');
//liElement4.style.borderRight = '1px solid #868686';
liElement3 = document.querySelector('#pt-logout');
liElement3.style.borderRight = '1px solid #404040';
liElement3.style.paddingRight = '0.5em';
// Get the parent <ul> element
ulElement = document.querySelector('.vector-menu-content-list.menu');
// Create a new <li> element
liElement = document.createElement('li');
liElement.id = 'pt-homepage';
liElement.className = 'mw-list-item';
// Create a new <a> element
linkElement = document.createElement('a');
linkElement.href = '/wiki/Satisfactory_Wiki';
linkElement.className = 'new';
linkElement.title = 'Home page';
// Create a new <span> element
spanElement = document.createElement('span');
spanElement.textContent = 'Home';
spanElement.style.color = 'var(--wiki-content-link-color)';
spanElement.style.fontWeight = 'bold';
// Append the <span> element to the <a> element
linkElement.appendChild(spanElement);
// Append the <a> element to the <li> element
liElement.appendChild(linkElement);
// Append the new <li> element to the parent <ul> element
ulElement.appendChild(liElement);
//second element
// Get the parent <ul> element
ulElement2 = document.querySelector('.vector-menu-content-list.menu');
// Create a new <li> element
liElement2 = document.createElement('li');
liElement2.id = 'pt-recentchanges';
liElement2.className = 'mw-list-item';
liElement2.style.borderRight = '1px solid #404040';
liElement2.style.paddingRight = '0.5em';
// Create a new <a> element
linkElement2 = document.createElement('a');
linkElement2.href = '/wiki/Special:RecentChanges';
linkElement2.className = 'new';
linkElement2.title = 'Recent Changes';
// Create a new <span> element
spanElement2 = document.createElement('span');
spanElement2.textContent = 'Recent Changes';
spanElement2.style.color = 'var(--wiki-content-link-color)';
spanElement2.style.fontWeight = 'bold';
// Append the <span> element to the <a> element
linkElement2.appendChild(spanElement2);
// Append the <a> element to the <li> element
liElement2.appendChild(linkElement2);
// Append the new <li> element to the parent <ul> element
ulElement2.appendChild(liElement2);
});