User:Cloudy's comment mover bot/global.js

// Copied from User:Cloudy176/global.js

// Opens all folders on enhanced recent changes var opensesame = function { if (wgCanonicalSpecialPageName === "Recentchanges" ) { array1 = document.getElementsByClassName("mw-made-collapsible"); for (i = 0; i < array1.length; i++) { tb = array1[i]; array2 = tb.children[0].children; for (j = 1; j < array2.length; j++) { array2[j].style.display = "table-row"; }       }    } };

var commentMover = function(destination, reason) { if(wgCanonicalSpecialPageName === "Prefixindex") { if(!wgPageName.endsWith("/")) { console.log("Page URL should end with /"); return; }       if(reason === undefined) { reason = "Moving%20comments%20not%20moved%20by%20FANDOMbot"; }       originalBaseName = document.URL.replace(wgServer + "/wiki/Special:PrefixIndex/", ""); listTable = document.getElementById("mw-prefixindex-list-table"); if(listTable === null) { console.log("No comments found."); return; }       tds = listTable.getElementsByTagName("td"); prevUrl = null; for(i = 0; i < tds.length; i++) { url = tds[i].firstChild.href; if(prevUrl === null || !url.startsWith(prevUrl)) { prevUrl = url; commentPart = url.replace(wgServer + "/wiki/" + originalBaseName, ""); newUrl = wgServer + "/wiki/Special:MovePage/" + originalBaseName + commentPart; newUrl += "?wpLeaveRedirect=0&wpMovesubpages=1"; newUrl += "&wpReason=" + reason; newUrl += "&wpNewTitle=" + destination + "/" + commentPart; console.log(newUrl); }       }    } };