您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Opens various links in pop-in window. This includes Giveaway links, links to Steam store and new messages.
当前为
// ==UserScript== // @name SteamGifts: Open in pop-in // @namespace lainscripts_steamgifts_steam_popin // @description Opens various links in pop-in window. This includes Giveaway links, links to Steam store and new messages. // @include http://www.steamgifts.com/* // @include https://www.steamgifts.com/* // @version 1.13 // @grant none // ==/UserScript== function svgSpinner(out_radius, in_radius, width, number_of_lines, period, direction) { var num = number_of_lines, shift = out_radius + width / 2, step = 0; var svg = '<svg id="spinner" version="1.1" x="0px" y="0px" width="' + (2 * shift) + 'px" height="' + (2 * shift) + 'px" xml:space="preserve" style="stroke:#fff;stroke-width:' + width + 'px;stroke-linecap:round;"><g>'; while (num--) { if (direction >= 0) step = num; else step = number_of_lines - num; svg += '<line x1="' + (shift + Math.cos(2 * Math.PI / number_of_lines * num) * in_radius) + '" y1="' + (shift + Math.sin(2 * Math.PI / number_of_lines * num) * in_radius) + '" x2="' + (shift + Math.cos(2 * Math.PI / number_of_lines * num) * out_radius) + '" y2="' + (shift + Math.sin(2 * Math.PI / number_of_lines * num) * out_radius) + '">' + '<animate attributeType="CSS" attributeName="opacity" from="1" to="0.1" dur="' + period + 's" repeatCount="indefinite" begin="' + (period * step / number_of_lines) + 's" /></line>'; } svg += '</g></svg>'; return svg; } function popinObj() { var spinner = document.createElement('div'); spinner.innerHTML = svgSpinner(45, 25, 10, 10, 1.8, -1); with (spinner.style) { position = 'fixed'; top = '50%'; left = '50%'; marginTop = '-50px'; marginLeft = '-50px'; width = '100px'; height = '100px'; } var popin = document.createElement('div'); with (popin.style) { boxSizing = 'border-box'; position = 'fixed'; top = 0; left = 0; padding = '45px 50px'; width = '100%'; height = '100%'; backgroundColor = 'rgba(0,0,0,0.85)'; display = 'none'; } var ifrm; var openFrame = function (url) { var ifr = document.createElement('iframe'); ifr.src = url; ifr.onload = function(){ spinner.style.display = 'none'; var y = (this.contentWindow || this.contentDocument); if (y.document) { [].forEach.call(y.document.querySelectorAll('header,.offer__outer-wrap'), function(i){ i.style.display = 'none'; }); [].forEach.call(y.document.querySelectorAll('a[href^="http"]:not([href*=".steamgifts."])'), function(i){ i.target = '_blank'; }); } }; with (ifr.style) { width = '100%'; height = '100%'; padding = '4px'; border = '#666 2px solid'; borderRadius = '3px'; backgroundColor = 'rgba(0,0,0,0.33)'; } return ifr; } popin.appendChild(spinner); document.body.appendChild(popin); this.show = function (url) { document.body.style.overflowY = 'hidden'; spinner.style.display = 'block'; setTimeout(function(){spinner.style.display='none';},5000); ifrm = openFrame(url); popin.insertBefore(ifrm, popin.childNodes[0]); popin.style.display = 'block'; }; this.hide = function () { document.body.style.overflowY = 'auto'; popin.style.display = 'none'; ifrm.parentNode.removeChild(ifrm); }; popin.onclick = this.hide; } var popin = new popinObj(); var lst = [ 'a[href*="/store.steampowered.com/"]', 'a[href^="/giveaway/"]:not(.sidebar__navigation__item__link)', '.nav__right-container a.nav__button', 'a.nav__button[href="/about/faq"]' ]; [].forEach.call(document.querySelectorAll(lst.join(',')), function (i) { i.onclick = function (e) { if (e.which === 2) return; var t = e.target; while (t.tagName.toLowerCase()!='a') t = t.parentNode; if (t.href) { if (t.parentNode.className != 'esg-join') { popin.show(t.href); e.preventDefault(); } } }; });