MediaWiki:Gadget-extra-hooks.js
From WikiMSK
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (โ-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (โ-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
// this gadget sets up all the extra hooks that the coppermind uses for it's other gadgets
mw.hook('wikipage.content').add(function extra_hooks(content) {
/// hook for catching particular pages
/**/{
const page_hook = mw.config.get('wgPageName')
console.debug('extra-hook:', page_hook)
mw.hook(page_hook).fire(content)
}
/// hook for catching particular namespace
/**/{
const ns_hook = 'mw-ns-'+ mw.config.get('wgNamespaceNumber')
console.debug('extra-hook:', ns_hook)
mw.hook(ns_hook).fire(content)
}
/// hook for catching different page actions
if (mw.config.get('wgAction') != 'view') {
const act_hook = 'mw-action.'+ mw.config.get('wgAction')
console.debug('extra-hook:', act_hook)
mw.hook(act_hook).fire(content)
}
/// hook for catching after a page has been saved
if (mw.config.exists('wgPostEdit')) {
const act_hook = 'mw-action.just-saved'
console.debug('extra-hook:', act_hook)
mw.hook(act_hook).fire(content)
}
})