ব্যবহারকারী:খাত্তাব হাসান/sand.js
লক্ষ্য করুন: প্রকাশ করার পর, পরিবর্তনগুলো দেখতে আপনাকে আপনার ব্রাউজারের ক্যাশে পরিষ্কার করার প্রয়োজন হতে পারে।
- ফায়ারফক্স / সাফারি: পুনরায় লোড-এ ক্লিক করার সময় শিফট টিপে ধরে রাখুন, অথবা হয় Ctrl-F5 বা Ctrl-R টিপুন (ম্যাকে ⌘-R টিপুন)
- গুগল ক্রোম: Ctrl-Shift-R (ম্যাকে ⌘-Shift-R) টিপুন
- ইন্টারনেট এক্সপ্লোরার / এজ: Ctrl ধরে রাখা অবস্থায় Refresh-এ ক্লিক করুন, অথবা Ctrl-F5 টিপুন
- অপেরা: Ctrl-F5 টিপুন।
// ==UserScript==
// @name Show Global Edit Counts
// @namespace https://en.wikipedia.org
// @description Shows the "Global edit counts (approximate)" section from XTools on a user's Wikipedia userpage.
// @include /^https?:\/\/(.*\.)?wikipedia\.org\/wiki\/User:(.*)$/
// @version 1.0
// @grant none
// ==/UserScript==
// Get the username from the URL
const username = mw.config.get('wgPageName').split('User:')[1];
// Get the global edit counts from XTools
fetch(`https://xtools.wmcloud.org/api/user/${username}/global`)
.then(response => response.json())
.then(data => {
// Get the global edit count
const globalEditCount = data.global_editcount;
// Get the global edit count on each wiki
const globalEditCounts = data.global_edits;
// Create a table to display the global edit counts
let table = '<table><tr><th>Wiki</th><th>Edit Count</th></tr>';
for (const count of globalEditCounts) {
table += `<tr><td>${count.wiki}</td><td>${count.count}</td></tr>`;
}
table += '</table>';
// Insert the table into the userpage
const mastheadInfo = document.querySelector('.masthead-info hgroup');
const newElement = document.createElement('div');
newElement.innerHTML = `
<p>Global Edit Count: ${globalEditCount}</p>
<h3>Global Edit Counts (approximate)</h3>
${table}
`;
mastheadInfo.appendChild(newElement);
});