diff --git a/README.md b/README.md index ed1151a..de1f8a4 100644 --- a/README.md +++ b/README.md @@ -203,7 +203,7 @@ If you would like to support my NFT collection, please take a look at the below. ### Added Opensea Selling Script -Added a new script `utils/opensea/sell_nfts.js` that will allow users to sell NFTs between two edition numbers (inclusive) to be put up for sale if the user owns the NFTs. This functionality uses Puppeteer and Chainsafe's Dappeteer, so please use at your own discretion as you will need to make use of your seed phrase for this functionality to work. [Feature - Opensea Polygon Script To Auto Sell NFTs](https://github.com/thepeanutgalleryandco/create-and-mint-nft-collection/issues/42) +Added a new script `utils/opensea/sell_nfts.js` that will allow users to sell NFTs between two edition numbers (inclusive) to be put up for sale if the user owns the NFTs. This functionality uses Puppeteer and Chainsafe's Dappeteer, so please use at your own discretion as you will need to make use of your seed phrase for this functionality to work. [Feature - Opensea Polygon Script To Auto Sell NFTs](https://github.com/thepeanutgalleryandco/create-and-mint-nft-collection/issues/42) and [Feature - Opensea Polygon Script To Auto Sell NFTs Additional Fields](https://github.com/thepeanutgalleryandco/create-and-mint-nft-collection/issues/47) ### Added Start Collection Edition Setting @@ -508,11 +508,11 @@ Use the `Opensea - Refresh_Metadata Command` below to start the refresh of meta ### 18. Sell NFTS On Opensea -Go to the utils/opensea/sell_nfts.js file and update the `START_EDITION`, `END_EDITION`, `NFT_PRICE` and potentially `seed` fields. Please make sure that the contract address that you are trying sell NFTs for has been set in the `contract_address` field in the `constants/account_details.js` file as well as that the `chain` value is correct for the specific contract address. +Go to the utils/opensea/sell_nfts.js file and update the `START_EDITION`, `END_EDITION`, `NFT_PRICE`, `DROPDOWN_OPTION`, `DATE_PICK_SKIP`, `START_HOUR`, `START_MINUTE`, `END_HOUR`, `END_MINUTE` and potentially `seed` fields. Please make sure that the contract address that you are trying sell NFTs for has been set in the `contract_address` field in the `constants/account_details.js` file as well as that the `chain` value is correct for the specific contract address. Use the `Opensea - Sell_Nfts Command` below to start the putting each NFT edition up for sale between your start and end editions for the given price. -[Feature - Opensea Polygon Script To Auto Sell NFTs](https://github.com/thepeanutgalleryandco/create-and-mint-nft-collection/issues/42) +[Feature - Opensea Polygon Script To Auto Sell NFTs](https://github.com/thepeanutgalleryandco/create-and-mint-nft-collection/issues/42) and [Feature - Opensea Polygon Script To Auto Sell NFTs Additional Fields](https://github.com/thepeanutgalleryandco/create-and-mint-nft-collection/issues/47) **Please read the warning very carefully within the the sell_nfts.js file with regards to the seed field.** **Please note that this script will only work with the Polygon network** diff --git a/package-lock.json b/package-lock.json index 6f66591..72926b5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "create-and-mint-nft-collection", - "version": "1.7.1", + "version": "1.7.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "create-and-mint-nft-collection", - "version": "1.7.0", + "version": "1.7.2", "license": "MIT", "dependencies": { "@chainsafe/dappeteer": "2.3.0", diff --git a/package.json b/package.json index 0af3ce1..5fc8584 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "create-and-mint-nft-collection", - "version": "1.7.1", + "version": "1.7.2", "description": "Source code to create and mint generative art via NFTPort API. Special thanks to codeSTACKr and Hashlips for their source codebase.", "main": "index.js", "bin": "index.js", diff --git a/utils/opensea/sell_nfts.js b/utils/opensea/sell_nfts.js index 54deb98..d0d7500 100644 --- a/utils/opensea/sell_nfts.js +++ b/utils/opensea/sell_nfts.js @@ -9,6 +9,12 @@ const { ACCOUNT_DETAILS } = require(`${FOLDERS.constantsDir}/account_details.js` const START_EDITION = 1; // Set the start edition of the collection where you want to start selling NFTs from. const END_EDITION = 1; // Set the end edition of the collection where you want to stop selling NFTs at. const NFT_PRICE = 0.002; // Set the price that will be given to each NFT between START_EDITION and END_EDITION. +const DROPDOWN_OPTION = 0; // Set the dropdown option to setup the date picker. Leave at 0 to keep the default sell timeframe. Do not add more options than what there is in the Opensea list. Do not count the default item in the list. +const DATE_PICK_SKIP = 7; // Set the tabs between the date picker drop down and the time. This value should be set between 6, 7 and 8. Please check the comment where this variable is used for more information. +const START_HOUR = 18; // Set the start hour for the sale. +const START_MINUTE = 00; // Set the start minute for the sale. +const END_HOUR = 23; // Set the end hour for the sale. +const END_MINUTE = 59; // Set the end minute for the sale. let COLLECTION_BASE_URL = ''; @@ -123,14 +129,46 @@ async function main() { // Go to the price input box and enter the price await page.waitForSelector('input[name=price]'); - await page.type('input[name=price]', `${NFT_PRICE}`, {delay: 25}); - - //TODO - // Go to the duration input box and enter the duration in days - //await page.focus('div[class^="Overflowreact__OverflowContainer-sc-7qr9y8-0"]'); - //await page.type('div[class^="Overflowreact__OverflowContainer-sc-7qr9y8-0"]', 'March 16, 2022 (11:49 PM) – April 13, 2022 (11:49 PM)'); - //March 16, 2022 (11:49 PM) – April 13, 2022 (11:49 PM) - + await page.type('input[name=price]', `${NFT_PRICE}`, {delay: 15}); + + // If drop down option is left at 0, then the default date, start and end hour will be used and will skip to the putting the item on sale. + // If drop down is populated with a positive number in the list, then navigate to that list item and choose it and also set the start date, end date and time + if (DROPDOWN_OPTION > 0) { + + // Navigate to the date picker + for (j=0; j < 3; j++) { + await page.keyboard.press('Tab', { page }); // navigate to button + } + + // Navigate to drop down option and choose it + for (j=0; j < DROPDOWN_OPTION; j++) { + await page.keyboard.press('Tab', { page }); // navigate to button + } + await page.keyboard.press('Space', { page }); // hit space button + + /* Go to the time picker + Please note that sometimes, the date picker will be out by a few presses, depending on the date that you are running the script on. + This happens when you are for example in a month of 31 days, and you are trying to go to a month that do not have 31 days + If you face this scenario, simply change the DATE_PICK_SKIP value to the right amount of tabs that is needed from + choosing the list item on the dropdown. You simply press the tab button after choosing the drop down item until you get to the time + picker. Count the number of tabs required and enter that amount at DATE_PiCK_SKIP at the top of the file. The value is usually between + 6, 7 and 8, but might need some tweaking. + */ + for (j=0; j < DATE_PICK_SKIP; j++) { + await page.keyboard.press('Tab', { page }); // navigate to button + } + + // Enter start time and end time + await page.keyboard.type(`${START_HOUR}`, {delay: 15}); + await page.keyboard.type(`${START_MINUTE}`, {delay: 15}); + await page.keyboard.press('Tab', { page }); // navigate to button + await page.keyboard.type(`${END_HOUR}`, {delay: 15}); + await page.keyboard.type(`${END_MINUTE}`, {delay: 15}); + + // Exit date picker + await page.keyboard.press('Tab', { page }); // navigate to button + } + // Go to the submit button and click it await page.waitForSelector('button[type=submit]'); await page.click('button[type=submit]'); @@ -138,9 +176,10 @@ async function main() { // Go to the sign button and click it await page.focus('div[aria-hidden="false"]'); - await page.keyboard.press('Tab', { page }); // navigate to button - await page.keyboard.press('Tab', { page }); // navigate to button - await page.keyboard.press('Tab', { page }); // navigate to button + + for (j=0; j < 3; j++) { + await page.keyboard.press('Tab', { page }); // navigate to button + } await page.keyboard.type('\n'); // hit enter await metamask.sign(); @@ -153,6 +192,9 @@ async function main() { // If any issues come up, then log the error and continue to the next edition console.log(`Error ${error} when attempting to put edition on sale: ${i}`); + + // Bring the main tab into view + await page.bringToFront(); } }