SteamworkshopViewer/src/index.js
2025-03-08 09:42:57 +01:00

48 lines
1.6 KiB
JavaScript

import './style.scss'
import Alpine from 'alpinejs'
import {defer} from "lodash";
import * as cheerio from 'cheerio';
window.Alpine = Alpine;
defer(() => Alpine.start());
document.addEventListener('alpine:init', () => {
Alpine.data('workshopList', () => ({
ids: '3428008364',
getModDescription() {
console.log("Load IDs", this.ids);
fetch('https://steamcommunity.com/sharedfiles/filedetails/?id=3428008364', {
method: "GET",
})
.then(res => {
const $ = cheerio.load(this.responseText);
console.log($('title'));
})
.catch(err => console.error);
// fetch('/api/ping', {
// method: "GET",
// }).then(res => console.log)
// .catch(err => console.error);
// let steamUrl = "/api/sharedfiles/filedetails/?id=";
// var xhttp = new XMLHttpRequest();
// xhttp.onreadystatechange = function() {
// if (this.readyState === 4 && this.status === 200) {
// //document.getElementById("demo").innerHTML = this.responseText;
// const $ = cheerio.load(this.responseText);
// console.log($('title'));
// console.log(this.responseText);
// }
// };
// xhttp.open("GET", steamUrl+this.ids, true);
// xhttp.send();
}
}))
});
document.addEventListener('alpine:initialized', () => {
//
});