Difference between revisions of "User:Fbstj/gadget/history-test.js"

m
try this
m (some debugging)
m (try this)
const api = new mw.Api()
const edit = document.querySelector('textarea')
const note = mw.notify('scanning for new files linking to '+ page_name)
console.log('editing', page_name, edit)
 
if (edit.value == '') {
edit.value = "'''"+ page_name.split('/')[1] +"''' made this art:\n\n<gallery>\n</gallery>\n\n== Notes ==\n<references />\n{{real world}}"
}
 
api.get({
const pid = Object.keys(resp.query.pages)[0]
const new_files = []
note.close()
if (!resp.query.pages[pid].linkshere) { consolemw.warnnotify('no files link to '+ page_name); return; }
const pages = resp.query.pages[pid].linkshere.map(function(page) { return page.title.split(':')[1] })
for (var i in pages) {
}
// don't change the page if there's nothing to change
if (new_files.length == 0) { consolemw.warnnotify('no new files link to '+ page_name); return; }
consolemw.lognotify('these files link to', page_name, new_files);
// TODO: make into a dropdown notice thing?
if (edit.value.includes('</gallery>')) {