Skip to content

Instantly share code, notes, and snippets.

@hungtcs
Last active April 11, 2020 06:49
Show Gist options
  • Save hungtcs/02da6ddb2cdd20476cf908fd27c36990 to your computer and use it in GitHub Desktop.
Save hungtcs/02da6ddb2cdd20476cf908fd27c36990 to your computer and use it in GitHub Desktop.
根据app-id直接添加游戏到愿望单
// ==UserScript==
// @name Steam Helper
// @namespace http://tampermonkey.net/
// @version 0.1
// @description steam额外帮助工具
// @author 鸿则<hungtcs@163.com>
// @match https://store.steampowered.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
const $ = window.jQuery;
const styles = `
.header-custom-actions-button {
color: #FFF;
height: 24px;
cursor: pointer;
padding: 0px 8px;
display: inline-flex;
align-items: center;
margin-right: 1rem;
vertical-align: top;
background-color: red;
}
`;
$('head').append($(`<style>${ styles }</style>`));
const customAction = $('<div class="header-custom-actions-button">额外工具</div>');
const customActionDropdown = $(`
<div class="popup_block_new" id="header-custom-actions-dropdown" style="display: none;">
<div class="popup_body popup_menu">
<a class="popup_menu_item action-add-to-wishlist">添加到愿望单</a>
</div>
</div>`
);
customAction.on('click', function() {
window.ShowMenu( this, 'header-custom-actions-dropdown', 'right', 'bottom', true );
});
customAction.insertBefore($('#global_action_menu'));
customActionDropdown.insertBefore($('#global_action_menu'));
customActionDropdown.find('.action-add-to-wishlist').on('click', function() {
const modal = window.ShowPromptDialog('添加到愿望单', '请输入appid', '确认', '取消');
modal.done(function(appid) {
window.AddToWishlist(appid, 'add_to_wishlist_area','add_to_wishlist_area_success','add_to_wishlist_area_fail','1_5_9__407' );
window.location = '/wishlist';
});
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment