// ==UserScript== // @name Free Competitors 2.0 // @namespace https://suod.madiator.com // @description Script to search and display software and recommendations // @license AGPLv3 // ==/UserScript== function searchSoftware() { const query = document.getElementById('searchBox').value; // Clear previous results and recommendations document.getElementById('results').innerHTML = ''; document.getElementById('recommendations').innerHTML = ''; fetch(`/software/${query}`) .then(response => response.json()) .then(data => displayResults([data])) .catch(error => console.error('Error:', error)); fetch(`/recommendations?q=${query}`) .then(response => response.json()) .then(data => displayRecommendations(data)) .catch(error => console.error('Error:', error)); } function displayResults(data) { const resultsSection = document.getElementById('results'); resultsSection.innerHTML = ''; data.forEach(software => { const softwareDiv = document.createElement('div'); softwareDiv.classList.add('software'); softwareDiv.innerHTML = `
${software.comment}
Platforms: ${software.platforms?.join(', ') ?? 'Unknown'}
Licenses: ${software.licenses?.join(', ') ?? 'Unknown'}
Interfaces: ${software.interface?.join(', ') ?? 'Unknown'}
Programming Languages: ${software.languages?.join(', ') ?? 'Unknown'}
Issues: ${software.issues?.join(', ') ?? 'None'}
Website Wikipedia `; resultsSection.appendChild(softwareDiv); }); } function displayRecommendations(data) { const recommendationsSection = document.getElementById('recommendations'); recommendationsSection.innerHTML = ''; data.forEach(({software, score}) => { const softwareDiv = document.createElement('div'); softwareDiv.classList.add('software'); softwareDiv.innerHTML = `Score: ${score}
${software.comment}
Platforms: ${software.platforms?.join(', ') ?? 'Unknown'}
Licenses: ${software.licenses?.join(', ') ?? 'Unknown'}
Interfaces: ${software.interface?.join(', ') ?? 'Unknown'}
Programming Languages: ${software.languages?.join(', ') ?? 'Unknown'}
Issues: ${software.issues?.join(', ') ?? 'None'}
Website Wikipedia `; recommendationsSection.appendChild(softwareDiv); }); }