Jump to content

User:Varenc/common.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
console.log("Varenc common.js loaded")


function purgePageCache(page_title) {
	
	fetch(`https://en.wikipedia.org/enwiki/w/index.php?title=${page_title}&action=purge`, {
	   method: "POST"
	})
	.then(response => {
	    if (response.ok) {
	        console.log(`Purge request successful: ${page_title}`);
	    } else {
	        console.log(`Purge request failed: ${page_title}`, response.status);
	    }
	})
	.catch(error => {
	    console.error(`Error making purge request on ${page_title}: `, error);
	});

}