Clear Steam Wishlist

Removes all games from steam wishlist

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

You will need to install an extension such as Tampermonkey to install this script.

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         Clear Steam Wishlist
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Removes all games from steam wishlist
// @author       gortik
// @license      MIT
// @match        https://store.steampowered.com/wishlist/profiles/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=steampowered.com
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    addHTML();
    // Your code here...
})();

function addHTML() {
	let parentElem = document.querySelector( '.control_row' );
	parentElem.insertAdjacentHTML( 'beforeend', '<div class="filter_tab" id="clear_wishlist" style="margin-left: 15px;"><span>Clear</span></div>' );
	document.querySelector( '#clear_wishlist' ).addEventListener( 'click', clearWishlist );
}

// 1st remove wasnt detecting enter
async function pressEnter( ) {
	// create a new keyboard event and set the key to "Enter"
	const key_down = new KeyboardEvent( 'keydown', {
		key: 'Enter',
		code: 'Enter',
		which: 13,
		keyCode: 13,
	});

	const key_up = new KeyboardEvent( 'keyup', {
		key: 'Enter',
		code: 'Enter',
		which: 13,
		keyCode: 13,
	});

	// dispatch the event on some DOM element
	document.dispatchEvent( key_down );
	await sleep( 250 );
	document.dispatchEvent( key_up );
	await sleep( 250 );
}

async function confirmRemove() {
	if ( !document.querySelector('.newmodal') ) {
		console.log( 'Modal wasnt created.' );
		return;
	}
	document.querySelector('.newmodal .btn_green_steamui').click();
	await sleep( 500 );
}


function sleep( ms ) {
        return new Promise( resolve => {
		console.log( 'Sleep: ' + ms/1000 + 's.' );
		setTimeout( resolve, ms )
	});
}

async function clearWishlist() {
	let	games = document.querySelectorAll( '.delete' );

	for ( let remove_elem of games ) {
		remove_elem.click();
		await sleep( 1000 );
		// modal window with ok/cancel buttons
		if ( document.querySelector('.newmodal') )
			confirmRemove();
	}
}

addHTML()