Last active
November 18, 2024 01:29
-
-
Save Chuvisco88/6875ba7cb28467e82dde06fcfc0b1a02 to your computer and use it in GitHub Desktop.
A small script for getting free stuff from the unity asset store
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
/* | |
HOW TO USE | |
########## | |
- Go to the unity asset store (https://assetstore.unity.com/) | |
- Select any category and adapt filters to what you want to get | |
It is recommended to set the "Hide Purchased Assets" and "Free Assets" to reduce working load. | |
You might also set other filters like for example only 3D Characters or 4+ star ratings only | |
- Open up the developer console (normally F12) | |
- Copy this script to the Console (you might change the consts at the beginning, numbers are in milliseconds) | |
- Write "redeemAll();" (without the quotes) in the console and hit enter | |
DISCLAIMER | |
########## | |
The script goes through all the assets it can find and tries to add them to your assets. | |
It automatically accepts the agreement popup, so you must be aware of the agreements. | |
Also the script seems to be rather flaky. | |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, | |
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | |
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF | |
THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
*/ | |
const showRedemptions = true; | |
const showNumberOfRedeemableProductsFoundOnCurrentPage = true; | |
const showAgreementAccepting = true; | |
const showMyAssetsOnlyAccepting = true; | |
const timePerProduct = 5000; | |
const timeUntilAgreementAcceptance = 1000; | |
const timeUntilMyAssetsOnly = 2500; | |
const timeBeforeGoingToNextPage = 10000; | |
function getAllProductDetails() { | |
return document.querySelectorAll('div.uty-prod-details'); | |
} | |
function getAllRedeemableAssets() { | |
return document.querySelectorAll('button[label="Add to My Assets"]'); | |
} | |
function getAcceptButton() { | |
return document.querySelector('button[label="Accept"]'); | |
} | |
function getAddToMyAssetsOnly() { | |
return document.querySelector('button[label="Add to my assets only"]'); | |
} | |
function getNextButton() { | |
return document.querySelector('button[label="Next"]:not(:disabled)'); | |
} | |
async function redeemCurrentPage(goToNextPage = false) { | |
console.log(`[INFO] Searching products on current page`); | |
const allProductDetails = Array.from(getAllProductDetails()); | |
const detailsOfFreeProducts = allProductDetails.filter(product => product.innerHTML.includes('FREE') && product.innerHTML.includes('Add to My Assets')); | |
if (showNumberOfRedeemableProductsFoundOnCurrentPage) { | |
console.log(`[INFO] Found ${detailsOfFreeProducts.length} products to redeem.`); | |
} | |
detailsOfFreeProducts.forEach(async (item, index) => { | |
setTimeout(function() { | |
const firstTextNode = item.querySelector('a div:first-of-type'); | |
const productName = firstTextNode ? firstTextNode.innerText : 'UNDEFINED'; | |
const addToMyAssetsButton = item.querySelector('button[label="Add to My Assets"]'); | |
if (showRedemptions) { | |
console.log(`[REDEMPTION] ${index+1}/${detailsOfFreeProducts.length} - ${productName}`); | |
} | |
addToMyAssetsButton.click(); | |
setTimeout(function() { | |
const acceptButton = getAcceptButton(); | |
if (acceptButton) { | |
if (showAgreementAccepting) { | |
console.log(`[INFO] Accepting agreement for ${productName}`); | |
} | |
acceptButton.click(); | |
} | |
}, timeUntilAgreementAcceptance); | |
setTimeout(function() { | |
const myAssetsOnly = getAddToMyAssetsOnly(); | |
if (myAssetsOnly) { | |
if (showMyAssetsOnlyAccepting) { | |
console.log(`[INFO] Adding ${productName} to my assets only`); | |
} | |
myAssetsOnly.click(); | |
} | |
}, timeUntilMyAssetsOnly); | |
}, index * timePerProduct); | |
}); | |
setTimeout(function() { | |
console.log('[INFO] Page should be done by now'); | |
const nextButton = getNextButton(); | |
if (goToNextPage && nextButton) { | |
console.log('[INFO] Going to next page'); | |
nextButton.click(); | |
setTimeout(function() { | |
console.log('[INFO] Start redeeming new page'); | |
redeemCurrentPage(goToNextPage); | |
}, timeBeforeGoingToNextPage); | |
} | |
}, detailsOfFreeProducts.length * timePerProduct + timeBeforeGoingToNextPage); | |
} | |
async function redeemAll() { | |
redeemCurrentPage(true); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
the script shows "undefined", how to solve this issue ?