Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <script>
- const do_get_age=false;
- let age_table= new Array();
- let name_table= new Array();
- let pending=false;
- let array_wanted_cities=["Sofia","СОФИЯ","Добринище","Dobrinishte","ЯКОРУДА","Yakoruda"];
- array_wanted_cities=[303, 303, 232, 232, 250, 250];
- function Html2Text(html="no-input-jon") {
- let text = html.replace(/<[^>]+>/g, ''); // Remove all HTML tags
- text = text.replace(/ /g, ' '); // Replace with empty space
- text = text.replace(/&/g, '&'); // Replace & with &
- text = text.replace(/>/g, '>'); // Replace > with >
- text = text.replace(/</g, '<'); // Replace < with <
- return text;
- }
- function isWeekend(date) {
- return (new Date(date).getDay() >= 6);
- }
- function extract_text(str, start_text, end_text){
- const regular = new RegExp(`${start_text}(.*?)${end_text}`);
- const match = str.match(regular);
- if (match) {
- return match[1];
- }
- }
- function extract_next_text(data, start_text, length=10){
- const part = data.substring(data.indexOf(start_text) + start_text.length, data.indexOf(start_text) + start_text.length + length);
- return part;
- }
- function checkIfFutureDate(given_date){
- const givenDate = new Date(given_date);
- const today = new Date();
- return givenDate > today;
- }
- function array_search_partial(keyword, arr) {
- for(let i = 0; i < arr.length; i++) {
- if (arr[i].includes(keyword)) {
- return i;
- }
- }
- }
- function fetch_tournament_data(tour_url="http://localhost"){
- let tourdata = ["NOT FOUND", "--", "---"];
- return fetch(tour_url)
- .then(response => response.text())
- .then(data => {
- const mytext = data;
- if (mytext.includes("To reduce the server load")) {
- return ["OLD", "<font color='darkred'>OLD-ARCHIVED</font>", "", ""];
- }
- const regex = /Arbiter(.*?)Pairing/;
- const match = mytext.match(regex);
- if (match) {
- let tourdata = match[1];
- let plaintext = new Html2Text().convert(tourdata);
- let array = plaintext.toString().split("\n");
- let date = extract_next_text(plaintext, "Date", 13);
- let location = extract_next_text(plaintext, "Location", 13);
- let timecontrol = extract_next_text(plaintext, "Time", 13);
- let ratingavg = array[array_search_partial('Rating-', array)];
- ratingavg = ratingavg.substr(9, 25);
- location = array[array_search_partial("Location", array)].substr(9);
- date = array[array_search_partial('Date', array)].substr(5, 25);
- timecontrol = array[array_search_partial("Time", array)].substr(12, 20);
- tourdata = [date, location, timecontrol, ratingavg];
- }
- return tourdata;
- });
- }
- let temp_keywords_pattern = '';
- let production_show = true;
- let country = "BUL";
- //let url = "https://corsproxy.io/?https://chess-results.com/fed.aspx?lan=1&fed=" + country;
- let url = "https://corsproxy.io/?https://chess-results.com/fed.aspx?lan=1&fed=" + country;
- let keywords_pattern = /(\bu12|u99|etc\b)/i;
- let fide_id=1111111;
- let player_url = "" + fide_id;
- let txt = "";
- let split_text = '<td class="CRc">';
- fetch(url)
- .then(response => response.text())
- .then(data => {
- let mytext = data;
- let result = mytext.toString().split(split_text);
- result[0] = "";
- console.log("result====="+result);
- result.forEach(text => {
- txt += text + "\n";
- });
- txt = new Html2Text(txt);
- let txt2 = txt.toString().split("\n");
- let end_result = "<ol>";
- txt2.forEach(string => {
- if (string.match(keywords_pattern)) {
- let matches = string.matchAll(/\[(.*?)\]/g);
- let name = matches[0][0].replace("[", "").replace("]", "");
- if (name.length < 4 || name.includes("Chess-Tournament-Results") || name.includes("Legal details")) {
- return;
- }
- let snr = string.match(/snr\=\d{1,3}/g)[0].replace("snr=", "");
- let tnr = string.match(/tnr\d{1,7}/g)[0].replace("tnr", "");
- let link = 'https://chess-results.com/tnr' + tnr + '.aspx?lan=1&turdet=YES';
- let tour_url = link;
- fetch_tournament_data(tour_url)
- .then(tourdata => {
- let date_only = tourdata[0].substr(0, 10);
- if (!checkIfFutureDate(date_only)) {
- end_result += '<FONT COLOR=red>OLD - </FONT></TD></tr>';
- return;
- }
- if (isWeekend(date_only)) {
- end_result += '<FONT COLOR=GREEN>WEEKEND- </FONT>';
- }
- if (tourdata[3] > 1500) {
- end_result += '<FONT COLOR=CYAN>[elo:' + tourdata[3] + ']</FONT>';
- }
- end_result += tourdata[1] + '</td><td>' + tourdata[0] + '</td><td>' + tourdata[2] + '</td><td>Elo:<BR>' + tourdata[3] + '</td>';
- end_result += "<td><input type='checkbox' name='selected_names[]' id='player' value='" + name + "' />";
- let name2 = name;
- end_result += "<b><a target=_blank href='" + link + "'>" + name2 + "|</a></b>--";
- end_result += "</td></tr>";
- });
- }
- });
- if (production_show) {
- document.getElementById("result").innerHTML = end_result;
- }
- });
- </script>
- </head>
- <body>
- <form action="" method="POST">
- <input type="text" value="BUL" name="country">
- <input type="submit">
- </form>
- <div id="result"></div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement