Skip to content

Instantly share code, notes, and snippets.

@geggo98
Last active November 18, 2022 17:10
Show Gist options
  • Save geggo98/49c2783c535a9bae98a0fdba0102302d to your computer and use it in GitHub Desktop.
Save geggo98/49c2783c535a9bae98a0fdba0102302d to your computer and use it in GitHub Desktop.
Autfill football tipps on kicktips.com
// ==UserScript==
// @name Auto Bet on Kicktipp for group "theocup2022"
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Autofill tip based on the betting quotes shown.
// @author You
// @match https://*.kicktipp.com/theocup2022/predict*
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant none
// ==/UserScript==
(function() {
'use strict';
const autoFill = (event) => {
event?.preventDefault();
console.log("Filling tip scores...");
const QUOTE_PATTERN = /\s*(?<home>\d*\.\d+)\s*\/\s*(?<draw>\d*\.\d+)\s*\/\s*(?<guest>\d*\.\d+)\s*/;
for (const row of document.querySelectorAll('#tippabgabeSpiele tr.datarow')) {
const quoteText = row.querySelector('a.wettquote-link')?.text;
if (!quoteText) continue;
const quotes = QUOTE_PATTERN.exec(quoteText);
if (!quotes) continue;
const homeQuote = parseFloat(quotes.groups.home);
const drawQuote = parseFloat(quotes.groups.draw);
const guestQuote = parseFloat(quotes.groups.guest);
const homeInput = row.querySelector('input[name*=heim]');
const guestInput = row.querySelector('input[name*=gast]');
if (drawQuote <= homeQuote && drawQuote <= guestQuote) {
homeInput.value = "1";
guestInput.value = "1";
} else if (guestQuote >= homeQuote) {
homeInput.value = "2";
guestInput.value = "1";
} else {
homeInput.value = "1";
guestInput.value = "2";
};
}
console.log("Filling winning countries...");
const COUNTRY_RANKING = ['Brazil', 'Belgium', 'Argentina', 'France', 'England', 'Italy', 'Spain', 'Netherlands', 'Portugal', 'Denmark', 'Germany', 'Croatia', 'Mexico', 'Uruguay', 'Switzerland', 'USA', 'Colombia', 'Senegal', 'Wales', 'IR Iran', 'Serbia', 'Morocco', 'Peru', 'Japan', 'Sweden', 'Poland', 'Ukraine', 'Korea Republic', 'Chile', 'Tunisia', 'Costa Rica', 'Nigeria', 'Russia', 'Austria', 'Czech Republic', 'Hungary', 'Algeria', 'Australia', 'Egypt', 'Scotland', 'Canada', 'Norway', 'Cameroon', 'Ecuador', 'Türkiye', 'Mali', 'Paraguay', 'Côte d\'Ivoire', 'Republic of Ireland', 'Qatar', 'Saudi Arabia', 'Greece', 'Romania', 'Burkina Faso', 'Slovakia', 'Finland', 'Venezuela', 'Bosnia and Herzegovina', 'Northern Ireland', 'Panama', 'Ghana', 'Iceland', 'Slovenia', 'Jamaica', 'North Macedonia', 'Albania', 'South Africa', 'Iraq', 'Montenegro', 'United Arab Emirates', 'Cabo Verde', 'Bulgaria', 'Congo DR', 'El Salvador', 'Oman', 'Israel', 'Uzbekistan', 'Georgia', 'China PR', 'Honduras', 'Gabon', 'Bolivia', 'Guinea', 'Jordan', 'Bahrain', 'Curaçao', 'Haiti', 'Zambia', 'Uganda', 'Syria', 'Benin', 'Luxembourg', 'Armenia', 'Palestine', 'Kyrgyz Republic', 'Vietnam', 'Belarus', 'Equatorial Guinea', 'Lebanon', 'Congo', 'Kenya', 'Madagascar', 'Mauritania', 'Trinidad and Tobago', 'New Zealand', 'India', 'Kosovo', 'Tajikistan', 'Estonia', 'Cyprus', 'Thailand', 'Korea DPR', 'Kazakhstan', 'Mozambique', 'Namibia', 'Guinea-Bissau', 'Sierra Leone', 'Guatemala', 'Angola', 'Libya', 'Niger', 'Faroe Islands', 'Azerbaijan', 'Malawi', 'Zimbabwe', 'Gambia', 'Togo', 'Sudan', 'Comoros', 'Tanzania', 'Antigua and Barbuda', 'Central African Republic', 'Philippines', 'Latvia', 'Turkmenistan', 'Solomon Islands', 'Rwanda', 'Ethiopia', 'Suriname', 'St. Kitts and Nevis', 'Burundi', 'Nicaragua', 'Eswatini', 'Lithuania', 'Hong Kong', 'Malaysia', 'Lesotho', 'Botswana', 'Kuwait', 'Liberia', 'Andorra', 'Indonesia', 'Dominican Republic', 'Maldives', 'Yemen', 'Afghanistan', 'Chinese Taipei', 'Myanmar', 'Papua New Guinea', 'Singapore', 'New Caledonia', 'Tahiti', 'Fiji', 'Vanuatu', 'South Sudan', 'Barbados', 'Cuba', 'Malta', 'Bermuda', 'Puerto Rico', 'Guyana', 'St. Lucia', 'Grenada', 'Moldova', 'Nepal', 'Belize', 'Cambodia', 'St. Vincent and the Grenadines', 'Montserrat', 'Mauritius', 'Chad', 'Macau', 'Mongolia', 'Dominica', 'Bhutan', 'São Tomé and Príncipe', 'Laos', 'American Samoa', 'Cook Islands', 'Brunei Darussalam', 'Samoa', 'Bangladesh', 'Djibouti', 'Pakistan', 'Cayman Islands', 'Liechtenstein', 'Tonga', 'Timor-Leste', 'Seychelles', 'Eritrea', 'Aruba', 'Bahamas', 'Somalia', 'Gibraltar', 'Guam', 'Turks and Caicos Islands', 'Sri Lanka', 'US Virgin Islands', 'British Virgin Islands', 'Anguilla', 'San Marino'];
for (const select of document.querySelectorAll('div.fragebox select')) {
if (!select.options) continue;
const options = [...select.options];
const topCountry = COUNTRY_RANKING.filter((country) => options.some((option) => option?.text?.localeCompare(country, undefined, { sensitivity: 'base' }) === 0))[0];
const topOption = options.filter((option) => option?.text === topCountry)[0];
const topValue = topOption?.value;
if (!topValue) continue;
select.value = topValue;
}
console.log("Filling in semi-finales");
const semiFinalesRow = [...document.querySelectorAll('td.cell.col1')].filter((td) => /Who will reach the semi-finals\?/.test(td.innerText))[0].parentElement;
const countriesAlreadySelected = [];
for (const select of semiFinalesRow.querySelectorAll('div.fragebox select')) {
if (!select.options) continue;
const options = [...select.options];
const topCountry = COUNTRY_RANKING.filter((country) => !countriesAlreadySelected.includes(country) && options.some((option) => option?.text?.localeCompare(country, undefined, { sensitivity: 'base' }) === 0))[0];
countriesAlreadySelected.push(topCountry);
const topOption = options.filter((option) => option?.text === topCountry)[0];
const topValue = topOption?.value;
if (!topValue) continue;
select.value = topValue;
}
};
const buttonTemplate = document.createElement('template');
// CSS from here: https://www.joshwcomeau.com/animation/3d-button/
buttonTemplate.innerHTML = `<style>
.pushable {
position: relative;
border: none;
background: transparent;
padding: 0;
cursor: pointer;
outline-offset: 4px;
transition: filter 250ms;
}
.shadow {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border-radius: 12px;
background: hsl(0deg 0% 0% / 0.25);
will-change: transform;
transform: translateY(2px);
transition:
transform
600ms
cubic-bezier(.3, .7, .4, 1);
}
.edge {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border-radius: 12px;
background: linear-gradient(
to left,
hsl(340deg 100% 16%) 0%,
hsl(340deg 100% 32%) 8%,
hsl(340deg 100% 32%) 92%,
hsl(340deg 100% 16%) 100%
);
}
.front {
display: block;
position: relative;
padding: 12px 42px;
border-radius: 12px;
font-size: 1.25rem;
color: white;
background: hsl(345deg 100% 47%);
will-change: transform;
transform: translateY(-4px);
transition:
transform
600ms
cubic-bezier(.3, .7, .4, 1);
}
.pushable:hover {
filter: brightness(110%);
}
.pushable:hover .front {
transform: translateY(-6px);
transition:
transform
250ms
cubic-bezier(.3, .7, .4, 1.5);
}
.pushable:active .front {
transform: translateY(-2px);
transition: transform 34ms;
}
.pushable:hover .shadow {
transform: translateY(4px);
transition:
transform
250ms
cubic-bezier(.3, .7, .4, 1.5);
}
.pushable:active .shadow {
transform: translateY(1px);
transition: transform 34ms;
}
.pushable:focus:not(:focus-visible) {
outline: none;
}
</style>
<button class="pushable" id="autofill">
<span class="shadow"></span>
<span class="edge"></span>
<span class="front">
Auto fill tips
</span>
</button>`;
document.querySelector("div.tabs").appendChild(buttonTemplate.content);
const autoFillButton = document.getElementById('autofill');
autoFillButton.addEventListener('click', autoFill);
})();
@geggo98
Copy link
Author

geggo98 commented Nov 18, 2022

To use this script:

  1. Install the Tampermonkey extension for your browser
  2. Click on the button "Raw" on this page
  3. Tampermonkey should prompt you to install this script image
  4. Go to Kicktipp
  5. Press the red button image
  6. Scroll down and review the tips
  7. If everything is fine, please remember to press "Submit predictions" at the bottom of the page

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment