Skip to content

Instantly share code, notes, and snippets.

@barneycarroll
Last active January 29, 2026 16:40
Show Gist options
  • Select an option

  • Save barneycarroll/2b5a420117ac3ae85115c8e3580f14e6 to your computer and use it in GitHub Desktop.

Select an option

Save barneycarroll/2b5a420117ac3ae85115c8e3580f14e6 to your computer and use it in GitHub Desktop.
Get ranked candidate endorsements from Your Party membership portal

Make sure you're logged in at https://in.yourparty.uk then navigate to your country or region:

Open the Javascript console in your browser:

Windows Mac
Chrome/Edge Command+Option+J Ctrl+Shift+J
Firefox Command+Option+K Ctrl+Shift+J

Then paste the following code, and hit Enter. The ranked results will display on the page and be copied to your clipboard.

// Get all the candidate popups and grab names and endorsements for both 
const candidates = Array.from(document.querySelectorAll('[id^=candidate]')).map($modal => {
    const name         = $modal.querySelector('.modal-title').textContent.slice(0, -2);
    const endorsements = $modal.querySelector('.modal-body > :last-child').textContent.split('currently has ')[1].split(' ')[0];

    return { name, endorsements };
})
    // Sort highest to lowest
    .sort((a, b) => b.endorsements - a.endorsements);

// Draw up a ranked table on the page
document.querySelector('h2').innerHTML += `
    <h3>Results as of ${new Date().toLocaleString()}:</h3>
    <table class="table table-striped" style="position: relative;border-collapse: collapse;">
        <thead>
            <tr style="background-color: #FAF6E8;position: sticky;top: 0;">
                <th>Candidate</th>
                <th>Endorsements</th>
            </tr>
        </thead>
        <tbody>
            ${candidates.map(candidate => `
                <tr>
                    <td>${candidate.name}</td>
                    <td>${candidate.endorsements}</td>
                </tr>
            `).join('')}
        </tbody>
    </table>
`;

// Copy to clipboard as text
copy(candidates.map(candidate => `${candidate.name}: ${candidate.endorsements}`).join('\n'));
// Get all the candidate popups and grab names and endorsements for both
const candidates = Array.from(document.querySelectorAll('[id^=candidate]')).map($modal => {
const name = $modal.querySelector('.modal-title').textContent.slice(0, -2);
const endorsements = $modal.querySelector('.modal-body > :last-child').textContent.split('currently has ')[1].split(' ')[0];
return { name, endorsements };
})
// Sort highest to lowest
.sort((a, b) => b.endorsements - a.endorsements);
// Draw up a ranked table on the page
document.querySelector('h2').innerHTML += `
<h3>Results as of ${new Date().toLocaleString()}:</h3>
<table class="table table-striped" style="position: relative;border-collapse: collapse;">
<thead>
<tr style="background-color: #FAF6E8;position: sticky;top: 0;">
<th>Candidate</th>
<th>Endorsements</th>
</tr>
</thead>
<tbody>
${candidates.map(candidate => `
<tr>
<td>${candidate.name}</td>
<td>${candidate.endorsements}</td>
</tr>
`).join('')}
</tbody>
</table>
`;
// Copy to clipboard as text
copy(candidates.map(candidate => `${candidate.name}: ${candidate.endorsements}`).join('\n'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment