< User:Σ | Testing facility
Browse history interactively ← Previous edit Next edit → Content deleted Content addedInline
Revision as of 04:53, 10 June 2020 view source Σ (talk | contribs )Autopatrolled , Extended confirmed users , IP block exemptions , Pending changes reviewers , Rollbackers 46,822 edits Deal with edit conflicts on stale pages by marking edit time as time of page load← Previous edit
Revision as of 04:59, 10 June 2020 view source Σ (talk | contribs )Autopatrolled , Extended confirmed users , IP block exemptions , Pending changes reviewers , Rollbackers 46,822 editsm Fix bug that the previous bug-fix introduced where it would no longer select subsections tooNext edit →
(One intermediate revision by the same user not shown)
Line 109:
Line 109:
sectionNumber = undefined;
sectionNumber = undefined;
if (validSections.hasOwnProperty(sectionNumber))
if (validSections.hasOwnProperty(sectionNumber))
editSection.innerHTML += " <span class=arky style=display:none><span class=mw-editsection-bracket>).attr(\"data-header\") > " + headerNum + " && $(archivable).hasClass(\"arkylink\") != $(this).hasClass(\"arkylink\")) { $(archivable).click(); } }'>archive</a><span class=mw-editsection-bracket>]</span></span>";
editSection.innerHTML += " <span class=arky style=display:none><span class=mw-editsection-bracket> == this) { continue; } if ($(archivable).attr(\"data-header\") > " + headerNum + " && $(archivable).hasClass(\"arkylink\") != $(this).hasClass(\"arkylink\")) { $(archivable).click(); } else { break ; } }'>archive</a><span class=mw-editsection-bracket>]</span></span>";
});
});
});
});
Revision as of 04:59, 10 June 2020
$.when( mw.loader.using(), $.ready).done( function () {
if (mw.config.get("wgNamespaceNumber") % 2 == 0 && mw.config.get("wgNamespaceNumber") != 4)
// not a talk page and not project namespace
return;
if (mw.config.get("wgNamespaceNumber") == -1)
// is a special page
return;
$("head").append("<style>a.arkylink { font-weight:bold } .arkyhighlight { background-color:#D9E9FF }</style>");
var validSections = new Object();
var fromTos = new Object();
var wikiText = "";
var revStamp = (new Date()).toISOString();
var startArchiveButton = mw.util.addPortletLink("p-cactions", "#", "ØCA", "pt-oeca", "Enter/exit the archival process", null, null);
var overlay = $(document.createElement("button"));
$(startArchiveButton).click(function(e) {
$(".arkylink").click();
$(".arky").toggle();
$("#archivebutton").toggle();
});
overlay.html("archive all the selected threads")
.attr("id", 'archivebutton')
.css("position", 'fixed')
.css("bottom", 0)
.css("height", '44px')
.css("width", '100%')
.css("font-size", '200%');
$(document.body).append(overlay);
overlay.toggle();
overlay.click(function(e) {
var numOfThreads, archiveTarget;
var sections, archiveThis;
var cutOffset, revisedPage;
function cut(s, start, end) {
return s.substr(0, start) + s.substring(end);
}
cutOffset = numOfThreads = 0;
revisedPage = wikiText;
sections = $("a.arkylink").map(function() {
return $(this).attr("data-section");
});
if (!(numOfThreads = sections.length))
return alert("No threads selected, aborting");
archiveTarget = prompt("Archiving " + numOfThreads + " threads: where should we move them to? (e.g. Misplaced Pages:Sandbox/Archive 1)", mw.config.get("wgPageName"));
if (!archiveTarget || archiveTarget == mw.config.get("wgPageName"))
return alert("No archive target selected, aborting");
sections.each(function(i, n) {
revisedPage = cut(
revisedPage,
fromTos - cutOffset,
fromTos - cutOffset
);
cutOffset += fromTos - fromTos;
});
archiveThis = sections.map(function() {
return wikiText.substring(fromTos, fromTos);
}).toArray().join("");
console.log("archive this:" + archiveThis);
console.log("revised page:" + revisedPage);
if (1) new mw.Api().postWithToken("csrf", {action: 'edit', title: mw.config.get("wgPageName"), text: revisedPage, summary: "Removed " + numOfThreads + " threads to ]", basetimestamp: revStamp, starttimestamp: revStamp})
.done(function(res1) {
alert("Successfully removed threads from talk page");
console.log(res1);
new mw.Api().postWithToken("csrf", {action: 'edit', title: archiveTarget, appendtext: "\n" + archiveThis, summary: "Added threads from ]"})
.done(function(res2) {
alert("Successfully added threads to archive page");
})
.fail(function(res2) {
alert("failed to add threads to archive page. manual inspection needed.");
})
.always(function(res2) {
console.log(res2);
window.location.reload();
});
})
.fail(function(res1) {
alert("failed to remove threads from talk page. aborting archive process.");
console.log(res1);
window.location.reload();
});
});
new mw.Api().get({action: 'parse', page: mw.config.get("wgPageName")}).done(function(dataShit) {
new mw.Api().get({action: 'query', pageids: mw.config.get("wgArticleId"), prop: , rvprop: }).done(function(shit) {
var rv;
rv = shit.query.pages.revisions;
wikiText = rv;
//revStamp = rv;
});
$(dataShit.parse.sections)
.filter(function(i, s) { return s.index == parseInt(s.index) })
.each(function(i, s) { validSections = s });
for (var i in validSections) {
i = parseInt(i);
fromTos = [
validSections.byteoffset,
validSections.hasOwnProperty(i+1)?validSections.byteoffset:Infinity
];
}
$("#mw-content-text").find(":header").find("span.mw-headline").each(function(i, title) {
var header, headerNum, editSection, sectionNumber;
header = $(this).parent();
headerNum = header.prop("tagName").substr(1, 1) * 1; // wtf javascript
editSection = header.find(".mw-editsection"); // 1st child
sectionNumber = header.find(".mw-editsection a:last");
if (sectionNumber) {
sectionNumber = sectionNumber.attr("href").match(/§ion=(\d+)/);
if (sectionNumber)
sectionNumber = sectionNumber;
} else // eg <h2>not a real section</h2>
sectionNumber = undefined;
if (validSections.hasOwnProperty(sectionNumber))
editSection.innerHTML += " <span class=arky style=display:none><span class=mw-editsection-bracket> == this) { continue; } if ($(archivable).attr(\"data-header\") > " + headerNum + " && $(archivable).hasClass(\"arkylink\") != $(this).hasClass(\"arkylink\")) { $(archivable).click(); } else { break; } }'>archive</a><span class=mw-editsection-bracket>]</span></span>";
});
});
});
Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.
**DISCLAIMER** We are not affiliated with Wikipedia, and Cloudflare.
The information presented on this site is for general informational purposes only and does not constitute medical advice.
You should always have a personal consultation with a healthcare professional before making changes to your diet, medication, or exercise routine.
AI helps with the correspondence in our chat.
We participate in an affiliate program. If you buy something through a link, we may earn a commission 💕
↑