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

m
try this
m (move to staff js)
m (try this)
 
document.querySelectorAll('.infobox,.navbar').forEach(add_editsection_link)
 
})
 
/* auto-fill [[Cite: Arcanum-@entry]] pages*/
$(function () {
 
const edit_box = document.querySelector('.editButtons')
// check that there is an edit box
if (!edit_box || mw.config.get('wgCanonicalNamespace') !== '') return
 
// check that it's a page creation
if (mw.config.get('wgArticleId') !== 0) return
 
// check that it's an Arcanum page
const page_name = mw.config.get('wgPageName')
if (!page_name.startsWith('Cite:Arcanum-')) return
 
const entry = page_name.split('-')[1]
const url = 'https://wob.coppermind.net/api/entry/'+ entry +'/'
fetch(url).then(reps => resp.json()).then(function (json) {
// deal with response
console.log('fetched '+url)
console.log(json)
})
 
})