您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Fixes header to the top of the page so it "moves with it" and adds a search input to it. In addition, adds a "more like this" button close to giveaway's image for searching by item (same as small icon close to the game's name, but more usable).
当前为
// ==UserScript== // @name [SteamGifts] Additional giveaway search tools // @description Fixes header to the top of the page so it "moves with it" and adds a search input to it. In addition, adds a "more like this" button close to giveaway's image for searching by item (same as small icon close to the game's name, but more usable). // @author MetalTxus // @version 1.2.5 // @include *//www.steamgifts.com* // @icon http://i.imgur.com/OG97ZbN.png // @namespace https://gf.qytechs.cn/users/8682 // ==/UserScript== /* Constants */ var STRINGS, HTML, SELECTORS, URLS, KEY_CODES, STYLE; STRINGS = { searchGiveaways: 'Search giveaways', moreLikeThis: 'Giveaways including this item' }; HTML = { searchInput: '<div class="nav__button-container"><input type="text" class="mt-search" placeholder="' + STRINGS.searchGiveaways + '"></input></div>', moreLikeThisButton: '<a class="mt-more-like-this white-gradient-background truncate" title="' + STRINGS.moreLikeThis + '"><i class="fa fa-search"></i></a>', enterAllButton: '<a href><i class="fa fa-check-square-o"></i> Enter All</a>' }; SELECTORS = { searchInput: '.mt-search', moreLikeThis: '.mt-more-like-this', es_enterButtons: '.widget-container > div:nth-child(2) > div:nth-child(3) .sidebar__entry-insert:not(.is-hidden)' }; URLS = { query: 'http://www.steamgifts.com/giveaways/search?q=' }; KEY_CODES = { enter: 13 }; STYLE = '<style> ' + // Overrides '.giveaway__heading .fa { font-size: 16px !important; } ' + 'header { position: fixed; top: 0; width: 100%; z-index: 42; } ' + '.featured__container { margin-top: 40px; } ' + '.sidebar__entry-insert, .sidebar__entry-delete, .sidebar__error, .sidebar__search { margin-bottom: 8px !important; min-width: 58px !important; } ' + // New '.mt-more-like-this { display: block !important; width: 30px; text-align: center; border: 1px solid; border-color: #E4E4E4 #CCCCCC #B4B4B4 #CCCCCC !important; border-radius: 4px; } ' + '.mt-more-like-this .fa { margin-bottom: 2px; } ' + '.mt-more-like-this:hover * { opacity: .85; } ' + '.mt-more-like-this:not(.sidebar__search) { margin: 0 !important; }' + '.mt-more-like-this.sidebar__search { width: 341px; height: 32px; line-height: 32px; padding: 0 8px; font-weight: bold; margin: 0 0 8px 0 !important; }' + '.white-gradient-background {' + 'background-image: linear-gradient(#FFFFFF 0%, #E5E5E5 100%) !important;' + 'background-image: -moz-linear-gradient(#FFFFFF 0%, #E5E5E5 100%) !important;' + 'background-image: -webkit-linear-gradient(#FFFFFF 0%, #E5E5E5 100%) !important;' + '} ' + '.truncate { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; } ' + '@media (max-width: 1024px) { ' + '.nav__button { padding: 0 6px !important; } ' + 'a.mt-more-like-this { display: none !important; } ' + '} ' + '</style>'; /* Global variables */ var searchInput, moreLikeThisButton; /* Flow */ initialize(); /* Functions */ function initialize () { $('head').append(STYLE); if (!$('.featured__container').length) $('.page__outer-wrap').css({ 'margin-top': '40px' }); $('.nav__left-container').eq(0).parent() .prepend(HTML.searchInput); var featuredInnerWrap = $('.featured__inner-wrap a').eq(0).attr('href'); if (featuredInnerWrap && featuredInnerWrap.indexOf('/giveaway/')) { var vanillaButton = $('.featured__summary a[href^="/giveaways/search?"]'); var gameName = $('.featured__heading__medium').text(); moreLikeThisButton = $(HTML.moreLikeThisButton); moreLikeThisButton.addClass('sidebar__search'); moreLikeThisButton.attr('href', vanillaButton.attr('href')); moreLikeThisButton.find('.fa').after(' <span>"' + gameName + '" giveaways</span>'); $('.sidebar > form').prepend(moreLikeThisButton); } searchInput = $(SELECTORS.searchInput); searchInput.keypress(onSearchInputKeyPress); addRowButtons(); setTimeout(function () { if ($('.sidebar__entry-custom').length) { var enterAllButton = $(HTML.enterAllButton); enterAllButton.click(enterAll); $('a[href="/account/settings/giveaways"]').after(enterAllButton); } }, 1); $(window).scroll(addRowButtons); } function addRowButtons () { $('.giveaway__row-inner-wrap:not(.mt)').each(function (i, element) { element = $(element); var vanillaButton = $(element).find('.giveaway__icon[href^="/giveaways/search?"]'); var button = $(HTML.moreLikeThisButton); button.attr('href', vanillaButton.attr('href')); element.find('.giveaway__columns').append(button); element.addClass('mt'); }); } function onSearchInputKeyPress (event) { if (event.keyCode === KEY_CODES.enter) { searchGiveaways(searchInput.val()); } } function searchGiveaways (query, inNewTab) { openLocation(URLS.query + query, inNewTab); } function openLocation (newLocation, inNewTab) { if (!!inNewTab) { window.open(newLocation); } else { location.href = newLocation; } } function enterAll (event) { event.preventDefault(); $(SELECTORS.es_enterButtons).click(); }
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址