-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# FitgirlScrape | ||
|
||
A simple POC for repack scraping, which only logs the result(s) to the console at the moment. Only tested on the index page of the site. | ||
|
||
## Install | ||
|
||
1. Install the Tampermonkey extension. ([Link](https://www.tampermonkey.net)) | ||
2. [Install](https://github.com/k3rielit/scripts/raw/main/fitgirl/fitgirlscrape.user.js) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// ==UserScript== | ||
// @name FitgirlScrape | ||
// @namespace http://tampermonkey.net/ | ||
// @version 0.1 | ||
// @description try to take over the world! | ||
// @author k3rielit | ||
// @match *://fitgirl-repacks.site/* | ||
// @icon https://www.google.com/s2/favicons?sz=64&domain=fitgirl-repacks.site | ||
// @grant none | ||
// ==/UserScript== | ||
|
||
(function() { | ||
'use strict'; | ||
|
||
function parseRepacks() { | ||
let repackNodes = document.querySelectorAll('article.type-post:not(.category-uncategorized)'); | ||
let repackList = []; | ||
repackNodes.forEach((article) => { | ||
let repackData = { | ||
post: {}, | ||
repack: { | ||
categories: [], | ||
downloads: [], | ||
features: [], | ||
}, | ||
game: {}, | ||
}; | ||
// Post information | ||
repackData.post.id = article.getAttribute('id'); | ||
repackData.post.title = article.querySelector('header.entry-header h1.entry-title a').innerText; | ||
repackData.post.page = article.querySelector('header.entry-header h1.entry-title a').href; | ||
// Repack information | ||
repackData.repack.id = article.querySelector('div.entry-content h3 span').innerText.replace('#', ''); | ||
article.querySelectorAll('div.entry-content ul').forEach((listNode, index) => { | ||
switch(index) { | ||
case 0: | ||
// Download links | ||
listNode.querySelectorAll('a').forEach((downloadNode) => { | ||
repackData.repack.downloads.push({ | ||
name: downloadNode.innerText, | ||
url: downloadNode.href, | ||
}); | ||
}) | ||
break; | ||
case 1: | ||
// Repack features | ||
listNode.querySelectorAll('li').forEach((repackFeatureNode) => { | ||
repackData.repack.features.push(repackFeatureNode.innerText); | ||
}); | ||
break; | ||
} | ||
}); | ||
article.querySelectorAll('header.entry-header div.entry-meta span.cat-links a').forEach((categoryNode) => { | ||
repackData.repack.categories.push({ | ||
name: categoryNode.innerText, | ||
url: categoryNode.href | ||
}); | ||
}); | ||
// Game information | ||
repackData.game.title = article.querySelector('div.entry-content h3 strong').innerText; | ||
repackData.game.url = article.querySelector('div.entry-content p a').href; | ||
repackData.game.metadata = article.querySelector('div.entry-content p').innerText.split('\n').filter(metadata => metadata); | ||
repackData.game.description = article.querySelector('div.su-spoiler-content').innerText; | ||
// Push the completed repack to the container | ||
repackList.push(repackData); | ||
}); | ||
return repackList; | ||
} | ||
|
||
// Observe and parse repack data | ||
const observer = new MutationObserver(() => { | ||
const repacks = parseRepacks(); | ||
console.log(repacks); | ||
}); | ||
// Start the observer | ||
observer.observe(document.body, { subtree: true, childList: true, attributes: true }); | ||
})(); |