-
Notifications
You must be signed in to change notification settings - Fork 0
/
ge2024-labour.user.js
39 lines (31 loc) · 1.2 KB
/
ge2024-labour.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// ==UserScript==
// @name GE24: Labour
// @namespace [email protected]
// @version 2024.03.06.0
// @author Stuart Orford
// @match https://vote.labour.org.uk/results
// @grant none
// @require https://code.jquery.com/jquery-3.4.1.min.js
// @require https://raw.githubusercontent.com/sjorford/js/master/sjo-jq.js
// ==/UserScript==
(function($) {
$(function() {
$(`<style>
.sjo-wrapper {background-color: white; color: black}
.sjo-wrapper td {padding: 0 0.5em;}
</style>`).appendTo('head');
var outputTable = $('<table class="sjo-table"></table>').prependTo('main')
.wrap('<div class="sjo-wrapper"></div>')
.click(() => outputTable.selectRange());
$('.grid > div').each((i,e) => {
var box = $(e);
var constituency = box.find('p').last().text().trim();
var candidate = box.find('p.font-bold').first().text().trim();
var incumbent = box.find('p:contains("Sitting MP")').text().trim();
var outputRow = $('<tr></tr>').appendTo(outputTable);
$('<td></td>').appendTo(outputRow).text(constituency);
$('<td></td>').appendTo(outputRow).text(candidate);
$('<td></td>').appendTo(outputRow).text(incumbent);
});
});
})(jQuery);