users distribution.js - dynamiccookies/postcrossing-wikipedia GitHub Wiki

This script queries every single row on the Countries and territories in Postcrossing webpage. It then automatically sorts the data and builds the code for two tables representing the countries with the most users and the most sent postcards respectively.

Steps

  1. Copy the code in users-distribution.js

  2. Using a Chrome or Edge browser, navigate to the Countries and territories in Postcrossing webpage

  3. Press the F12 key to open the Developer Tools pane

  4. In the Console pane that just opened, paste the code you copied in Step 1

  5. Press Enter and the script should run and successfully return the results

  6. The results should already be copied to your clipboard, but if they're not, select all of the text returned, starting with ==Users distribution== and ending with the last |} and copy it

  7. Now navigate to the Postcrossing Wikipedia page's Users distribution edit page

  8. Select everything in the edit pane and paste your code to replace it

  9. Click the 'Show preview' button to confirm the tables have been updated

  10. If everything looks good, scroll back down to the edit pane and click the blue 'Publish changes' button

Thank you for helping keep the Postcrossing Wikipedia page up to date!




Each HTML Table Row Converts From This:

<tr>
	<td style="text-align:center">
		<a href="/country/RU">RU</a>
	</td>
	<td sorttable_customkey="182">
		<a title="Russia flag" href="/country/RU"><i class="flag flag-RU"></i></a>
		<a href="/country/RU">Russia</a>
	</td>
	<td style="text-align:right" sorttable_customkey="109808">
		109,808
	</td>
	<td style="text-align:right" sorttable_customkey="7376977">
		7,376,977
	</td>
	<td style="text-align:right" sorttable_customkey="144478050">
		144,478,050
	</td>
</tr>

To This:

|-
|1.||{{flag|Russia}}||109,808

Or This:

|-
|2.||{{flag|Russia}}||7,376,977
⚠️ **GitHub.com Fallback** ⚠️