User:Greg Tyler/watchlist.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
![]() | Documentation for this user script can be added at User:Greg Tyler/watchlist. |
// TODO: Indicate to the user that pages are hidden from view.
addOnloadHook(function()
{
// WatchlistConfig = unsafeWindow.WatchlistConfig, wgPageName = unsafeWindow.wgPageName;
WatchlistConfig = {
ignorePages : {a:'Talk:Twitter',b:'Sports game'},
};
// The current page is the Watchlist
if (wgPageName == 'Special:Watchlist' && typeof(WatchlistConfig) !== 'undefined' && typeof(WatchlistConfig.ignorePages) !== 'undefined' && WatchlistConfig.ignorePages.length > 0)
{
nodes_to_remove = [];
// The user is using Enhanced Changes
if (window.toggleVisibility)
{
// TODO: Make this work.
}
else
{
days = document.getElementById('bodyContent').getElementsByTagName('ul');
for (day in days)
{
change = days[day].firstChild;
nodes_to_remove = [];
while (change)
{
pages = []
set_page_variable(5);
set_page_variable(7);
set_page_variable(8);
ignore_pages = WatchlistConfig.ignorePages;
for (ignore_page = 0; ignore_page < ignore_pages.length; ignore_page++)
{
for (page in pages)
{
if (ignore_pages[ignore_page] == pages[page].nodeValue)
nodes_to_remove.push(change);
}
}
change = change.nextSibling;
}
// TODO: Replace 'removeChild' with 'replaceChild'; the node is replaced with '→' with a negative margin so that it is shifted to the left.
for (node = 0; node < nodes_to_remove.length; node++)
days[day].removeChild(nodes_to_remove[node]);
}
}
}
function set_page_variable(node_index)
{
if (typeof(change.childNodes[node_index]) !== 'undefined' && change.childNodes[node_index].firstChild !== null)
pages.push(change.childNodes[node_index].firstChild);
}
});