|
|
| (একই ব্যবহারকারী দ্বারা সম্পাদিত ১৫টি মধ্যবর্তী সংশোধন দেখানো হচ্ছে না) |
| ১ নং লাইন: |
১ নং লাইন: |
| mw.loader.using(['mediawiki.util', 'mediawiki.api'], function () { | | mw.notify("My userscript loaded!"); |
| $(function () {
| |
| // Prevent script from running on Special pages (which cannot be purged)
| |
| if (mw.config.get('wgNamespaceNumber') < 0) return;
| |
| | |
| // Add the Portlet Link
| |
| var purgeLink = mw.util.addPortletLink(
| |
| 'p-cactions', // Target the "More" dropdown (Vector) or Actions tab (Monobook)
| |
| '#', // Link destination (handled by click event below)
| |
| 'Purge', // The visible text
| |
| 'ca-purge', // DOM ID for the link
| |
| 'Purge cache and update links', // Tooltip
| |
| '*' // Keyboard shortcut (Alt+Shift+*)
| |
| );
| |
| | |
| // Handle the click event
| |
| $(purgeLink).on('click', function (e) {
| |
| e.preventDefault(); // Stop the link from following '#'
| |
| | |
| // Change text to indicate processing
| |
| $(this).find('a').text('Purging...');
| |
| | |
| // Call the API
| |
| new mw.Api().post({
| |
| action: 'purge',
| |
| titles: mw.config.get('wgPageName'),
| |
| forcelinkupdate: 1 // This performs the "Hard Purge" (updates tables)
| |
| }).then(function () {
| |
| // On success, reload the page
| |
| location.reload();
| |
| }).catch(function () {
| |
| // If API fails, fallback to the standard confirmation screen
| |
| window.location.href = mw.util.getUrl(null, { action: 'purge' });
| |
| });
| |
| });
| |
| });
| |
| });
| |