Guest User

Untitled

a guest
Jul 24th, 2024
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.61 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Steam Market - Delete ALL lots
  3. // @namespace Shmurdik
  4. // @version 0.3
  5. // @description Steam Market - Delete ALL lots
  6. // @author Shmurdik
  7. // @match https://steamcommunity.com/market/
  8. // @match https://steamcommunity.com/market/listings/*
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14. if(typeof(Storage) == "undefined") {alert("Sorry, your browser does not support web storage..."); return;}
  15.  
  16. $J('#tabContentsMyListings').before('<a href="#delete_all_lots" class="item_market_action_button item_market_action_button_edit nodisable"><span id="delete_all_lots" class="item_market_action_button_contents"> Удалить ВСЕ лоты </span></a>');
  17.  
  18. if(localStorage.steammarketdeletealllotsinprogress) {DeleteCurrentLots();}
  19.  
  20. function DeleteCurrentLots(){
  21. $J(document).bind( "dblclick", function() {
  22. if(confirm("Отмена?")) {localStorage.removeItem("steammarketdeletealllotsinprogress"); location.reload();}
  23. });
  24. localStorage.steammarketdeletealllotsinprogress = 1;
  25. var deleted = 0;
  26. var total = $J('#tabContentsMyActiveMarketListingsTable').find('div.market_listing_cancel_button').length;
  27. if(total <= 0) { alert('Not found lots. Nothing to do.'); localStorage.removeItem("steammarketdeletealllotsinprogress"); return false; }
  28. var modal = ShowBlockingWaitDialog( 'Выполнение...', 'Пожалуйста, подождите пока выполнятся все запросы. Ошибки игнорируются.' );
  29. var requests = 0;
  30. var requestsStep = 5;
  31. var intervalId = setInterval(function() {
  32. $J('#tabContentsMyActiveMarketListingsTable').find('div.market_listing_cancel_button').slice(requests, requests + requestsStep).each(function(i, el){
  33. var res = $J(this).html().match(/RemoveMarketListing\('[\/]?mylisting', '(\d+)', (\d+), '(\d+)', '(\d+)'/i);
  34. if(!res) {res = $J(this).html().match(/type="checkbox" class="lfremove" data-listingid="(\d+)"/i);}
  35. if(res){
  36. jQuery.post('//steamcommunity.com/market/removelisting/'+res[1],
  37. {sessionid: g_sessionID}
  38. ).always(function(data){
  39. deleted++;
  40. modal.Dismiss();
  41. if(deleted >= total)
  42. {
  43. modal = ShowBlockingWaitDialog( 'Выполнение...', 'Текущая страница завершена. Перезагрузка через 5 секунд..' );
  44. clearInterval(intervalId);
  45. setTimeout(function() { location.reload(); }, 5000);
  46. }
  47. else
  48. {
  49. modal = ShowBlockingWaitDialog( 'Выполнение...', 'Удалено <b>' + deleted + '</b> из ' + total + '.' );
  50. }
  51. });
  52. }
  53. else
  54. {
  55. modal.Dismiss();
  56. modal = ShowBlockingWaitDialog( 'Ошибка!', 'Не найдена страница с лотами.' );
  57. }
  58. });
  59. requests += requestsStep;
  60. if(requests >= total) {
  61. clearInterval(intervalId);
  62. }
  63. }, 2000);
  64. }
  65. $J("#delete_all_lots").click(function(){
  66. if(confirm("Удалить ВСЕ лоты?")) {DeleteCurrentLots();}
  67. });
  68. })();
Advertisement
Add Comment
Please, Sign In to add comment