-
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
obsfx
committed
Jun 10, 2020
0 parents
commit e6e9df0
Showing
10 changed files
with
358 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 @@ | ||
/node_modules |
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,13 @@ | ||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | ||
Version 2, December 2004 | ||
|
||
Copyright (C) 2004 Sam Hocevar <[email protected]> | ||
|
||
Everyone is permitted to copy and distribute verbatim or modified | ||
copies of this license document, and changing it is allowed as long | ||
as the name is changed. | ||
|
||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | ||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION | ||
|
||
0. You just DO WHAT THE FUCK YOU WANT TO. |
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,51 @@ | ||
# itch.io bundle claimer | ||
|
||
[Bundle for Racial Justice and Equality](https://itch.io/b/520/bundle-for-racial-justice-and-equality) | ||
|
||
A simple script that is using `selenium` to help you for adding all bundle items | ||
to your library by clicking all download buttons in place of you. | ||
|
||
 | ||
|
||
### Prerequisites | ||
|
||
1. Download appropriate chrome driver for your operating system and add it to the PATH. | ||
2. Add chrome to the PATH. It should be accessible as 'google-chrome'. | ||
3. And of course nodejs and npm. | ||
|
||
### Usage | ||
|
||
1. Clone the repo | ||
|
||
``` | ||
git clone https://github.com/obsfx/itchio-bundle-claimer.git | ||
cd itchio_bundle_claimer | ||
npm install | ||
``` | ||
|
||
2. Run chrome in remote debugging mode | ||
|
||
(port '9000' must be available) | ||
|
||
``` | ||
npm run run-chrome | ||
``` | ||
|
||
3. Open a new chrome window and type `127.0.0.1:9000` at the address bar. | ||
|
||
 | ||
|
||
4. Click that the `about:blank` | ||
|
||
5. Type and go to `itch.io` by using that sub address bar. | ||
|
||
 | ||
|
||
6. Login by defeating that annoying captcha. After you logged in you can close the browser. | ||
|
||
7. Run the script. | ||
|
||
``` | ||
node index.js --pages=<specify the page count> --url=<specify the bundle page url that listed all download buttons> | ||
e.g.: node index.js --pages=48 --url=https://itch.io/bundle/download/sakfjasfkhaslkjfhlkajsfhgjkhlasf | ||
``` |
Binary file not shown.
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,76 @@ | ||
const minimist = require('minimist'); | ||
|
||
const { Builder, By, until } = require('selenium-webdriver'); | ||
const chrome = require('selenium-webdriver/chrome'); | ||
|
||
const options = new chrome.Options(); | ||
|
||
// setting 'debuggerAddress' | ||
// reference: https://stackoverflow.com/a/42095309 | ||
options.options_['debuggerAddress'] = '127.0.0.1:9000'; | ||
|
||
const argv = minimist(process.argv.slice(2)); | ||
|
||
if (typeof argv.pages != 'number' || typeof argv.url != 'string') { | ||
console.log('please be sure you passed parameters correct.'); | ||
return process.exit(0); | ||
} | ||
|
||
const PAGE_COUNT = Number(argv.pages) || 0; | ||
const BUNDLE_DOWNLOAD_URL = argv.url || ''; | ||
|
||
const ANCHOR_DOWNLOAD_CLASSNAME = 'button game_download_btn'; | ||
const BTN_DOWNLOAD_SELECTOR = 'button[value=claim]'; | ||
const AFTER_CLICK_LOAD_CLASSNAME = 'nav_btn return_link'; | ||
const GAME_NAME_SELECTOR = '.stat_header_widget .text_container .object_title'; | ||
|
||
let state = { | ||
counter: 0, | ||
downloadBtns: [], | ||
} | ||
|
||
const getDownloadBtns = async driver => { | ||
|
||
let anchorDownloads = await driver.findElements(By.className(ANCHOR_DOWNLOAD_CLASSNAME)); | ||
let buttonDownloads = await driver.findElements(By.css(BTN_DOWNLOAD_SELECTOR)); | ||
|
||
return [ ...anchorDownloads, ...buttonDownloads ]; | ||
} | ||
|
||
(async () => { | ||
const driver = await new Builder() | ||
.forBrowser('chrome') | ||
.setChromeOptions(options) | ||
.build(); | ||
|
||
for (let i = 1; i <= PAGE_COUNT; i++) { | ||
let URL = `${BUNDLE_DOWNLOAD_URL}?page=${i}`; | ||
|
||
await driver.get(URL); | ||
|
||
console.log('PAGE: ', i); | ||
console.log('current url:', await driver.getCurrentUrl()); | ||
console.log('-----------------------------------------') | ||
|
||
state.allDownloadBtns = await getDownloadBtns(driver); | ||
|
||
for (let j = 0; j < state.allDownloadBtns.length; j++) { | ||
|
||
await driver.executeScript('arguments[0].click();', state.allDownloadBtns[j]); | ||
|
||
await driver.wait( | ||
until.elementLocated(By.className(AFTER_CLICK_LOAD_CLASSNAME)), | ||
5000); | ||
|
||
let head = await driver | ||
.findElement(By.css(GAME_NAME_SELECTOR)) | ||
.getText(); | ||
|
||
console.log(++state.counter, head); | ||
|
||
await driver.get(URL); | ||
state.allDownloadBtns = await getDownloadBtns(driver); | ||
} | ||
} | ||
|
||
})(); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,15 @@ | ||
{ | ||
"name": "itchio_bundle_claimer", | ||
"version": "1.0.0", | ||
"main": "index.js", | ||
"scripts": { | ||
"prepare-chromedriver": "unzip ./chromedriver_linux64.zip && sudo mv ./chromedriver /usr/bin/chromedriver", | ||
"run-chrome": "google-chrome --remote-debugging-port=9000 --headless --no-sandbox --disable-setuid-sandbox --disable-gpu" | ||
}, | ||
"author": "obsfx", | ||
"license": "WTFPL", | ||
"dependencies": { | ||
"minimist": "^1.2.5", | ||
"selenium-webdriver": "^4.0.0-alpha.7" | ||
} | ||
} |