Last active
December 15, 2015 21:19
-
-
Save vitaly-zdanevich/a7a7f7a87083c7a23ab3 to your computer and use it in GitHub Desktop.
VK: market: set price for all visible (loaded at current page) products in category
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
var price = 190000; | |
var sleepTime = 3000; // ms | |
var itemsAll = document.querySelectorAll('.market_row_inner_cont'); | |
var items = []; | |
var i = 0; | |
for (var j = 0; j < itemsAll.length; j++) { | |
var priceOrig = itemsAll[j].querySelector('.market_row_price').innerHTML.replace(/,/g, '').replace(' rub.', ''); | |
if (priceOrig != price) { | |
items.push(itemsAll[j].querySelector('.market_row_inner_cont a')); | |
} | |
} | |
var time = sleepTime / 1000 * 3 * items.length / 60; | |
console.log('All products on page: ' + itemsAll.length + ', with different price: ' + items.length + | |
'; we need ' + (Math.round(time) + 1) + ' minutes'); | |
function correctPriceInCurrentCategory() { | |
items[i].click(); // open product | |
console.log('current product: ' + (i + 1) + '/' + items.length); | |
setTimeout(openBoxEditor, sleepTime); | |
} | |
function openBoxEditor() { | |
Market.showEditBox(cur.options.itemId, cur.options.itemOwnerId); // open edit box | |
setTimeout(setPrice, sleepTime); | |
} | |
function setPrice() { | |
document.getElementById('item_price').value = price; | |
document.querySelector('.market_box_btn').click(); // save & close | |
i++; | |
setTimeout(correctPriceInCurrentCategory, sleepTime); // recursion - set price for next product | |
} | |
correctPriceInCurrentCategory(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment