User:মোহাম্মদ মারুফ/crossWiki.js

Source: 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.
/*
 ****************************************
 *** ব্যবহারকারী:মোহাম্মদ মারুফ/crossWiki.js: crossWiki module
 ****************************************
 * This module is used to edit pages on other wikis.
 * It is used by the crossWiki module.
 * created by: [[w:bn:User:মোহাম্মদ মারুফ]]
 * License: CC-BY-SA 3.0
 * Version: 1.0
 * Last updated: 2022-12-10
 * Documentation: https://bn.wikipedia.org/wiki/ব্যবহারকারী:মোহাম্মদ মারুফ/crossWiki
 * Source: https://bn.wikipedia.org/wiki/ব্যবহারকারী:মোহাম্মদ মারুফ/crossWiki.js
 */
(function () {
  // check if mr is defined
  if (typeof window.mr === "undefined") {
    // if not, define it
    mr = new Object();
  }
  mr.cross = editForeignPage;
  // This is the main function that will be called by the user
  function editForeignPage(info, success, error) {
    // Custom hooks for edit success / failure (e.g., console.log)
    var errorHook = typeof error === "function", // has error function?
      successHook = typeof success === "function"; // has success hook?

    // Most "modern" browsers except IE support CORS
    if (!$.support.cors) {
      error("Your browser does not support CORS! Try Firefox.", "cors");
      return;
    }
    var api = new mw.ForeignApi(info.url + "/w/api.php");
    var params = { ...info };
    api
      .postWithToken("csrf", params)
      .done(function (data) {
        console.log(data);
      })
      .fail(function (data) {
        alert("কিছু সমস্যা হয়েছে");
        console.log(data);
      });
  }
})();