您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Export steam keys and mark them as used
当前为
- // ==UserScript==
- // @name Groupees - Keys Exporter
- // @icon https://groupees.com/favicon.ico
- // @namespace Royalgamer06
- // @author Royalgamer06
- // @version 1.1.4
- // @description Export steam keys and mark them as used
- // @include *://groupees.com/*
- // @grant unsafeWindow
- // @require https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js
- // ==/UserScript==
- //CONFIGURATION
- //Mark keys as used when exporting?
- const markUsed = true;
- //Export purchased products that have been revealed already too?
- const includeRevealed = true;
- //Add a white line between each item in the export window?
- const addWhiteLine = true;
- //Put the key on a new line after the game name?
- const keyOnNewLine = true;
- //What separates the game name and the key?
- const keySeparator = "";
- //CODE
- this.$ = this.jQuery = jQuery.noConflict(true);
- $(document).ready(function() {
- init();
- });
- function init() {
- if (/^https?:\/\/groupees\.com\/purchases\/?((\?|#).*)?$/.test(location.href)) {
- addExportButtonOld();
- }
- if (/^https?:\/\/groupees\.com\/profile\/products\/?((\?|#).*)?$/.test(location.href)) {
- addExportButtonNew();
- }
- }
- function addExportButtonNew() {
- $("#product_filters .col-md-3:last").append('<a class="btn btn-block btn-export-products"><span class="g-icon-2x g-icon-external-link"></span> Export Keys</a>');
- $(".btn-export-products").click(exportNew);
- }
- function exportNew() {
- $(".btn-export-products").html('<span class="g-icon-2x g-icon-spinner" style="display: inline-block;"></span> Exporting...').attr("disabled", "disabled");
- var deg = 0;
- var spinner = setInterval(function() {
- if ($(".btn-export-products .g-icon-spinner").length > 0) {
- deg++;
- $(".btn-export-products .g-icon-spinner").css("transform", "rotate(" + deg + "deg)").css("-webkit-transform", "rotate(" + deg + "deg)").css("-moz-transform", "rotate(" + deg + "deg)").css("-o-transform", "rotate(" + deg + "deg)");
- } else {
- clearInterval(spinner);
- }
- }, 5);
- var filters = "";
- $(".product-filter-options input:checked").each(function() {
- filters += "&" + this.id.replace("_", "=");
- });
- loadNextPages(1, [], filters);
- }
- function continueExportNew(productData) {
- unsafeWindow.productData = productData;
- var exportData = [];
- var productCount = productData.length;
- $(productData).each(function(index) {
- let i = index;
- let pid = this.pid;
- let game = this.game;
- if (!(this.revealed || !includeRevealed)) {
- unsafeWindow.$.post("/user_products/" + pid + "/reveal", function() {
- unsafeWindow.$.ajax({
- url: "/profile/products/" + pid,
- type: "GET",
- dataType: "script",
- success: function(s) {
- if (s.match(/data-id=\\\'[0-9]+\\\'>\\n/g) !== null) {
- let kid = s.match(/data-id=\\\'[0-9]+\\\'>\\n/g)[0].split("\\'")[1];
- unsafeWindow.$.post("/activation_codes/" + kid + "/reveal", function(data) {
- let key = data.code;
- exportData.push({ game: game, key: key });
- unsafeWindow.exportData = exportData;
- if (markUsed) unsafeWindow.$.post("/activation_codes/" + kid + "/lock");
- }).always(function() {
- if (i === productCount - 1) {
- setTimeout(function() {
- var win = window.open("", "Groupees Keys Export", "width=480,height=640");
- $(exportData.sort(SortByGame)).each(function() {
- win.document.write(this.game + keySeparator + (keyOnNewLine ? "<br>" : "") + this.key + (addWhiteLine ? "<br><br>" : "<br>"));
- });
- selectAll(win);
- $(".btn-export-products").html('<span class="g-icon-2x g-icon-external-link"></span> Export Keys').removeAttr("disabled");
- }, 1000);
- }
- });
- }
- }
- });
- });
- }
- });
- }
- function loadNextPages(page, productData, filters) {
- $.ajax({
- url: "/profile/products?page=" + page + filters,
- type: "GET",
- success: function(data) {
- if ($("#products_loader", data).length > 0) {
- $(".product-cell:has(.g-icon-game)", data).each(function() {
- var pid = $(this).attr("data-id");
- var game = $(this).find("h4[title]").attr("title");
- var revealed = $(this).find(".btn-reveal-product").length > 0;
- productData.push({ pid: pid, game: game, revealed: revealed });
- });
- loadNextPages(page + 1, productData, filters);
- } else {
- continueExportNew(productData);
- }
- }
- });
- }
- function addExportButtonOld() {
- $(".pre-nav").append('<button style="float:right;" id="exportUnused">Export Unused Keys</button>');
- $("#exportUnused").click(exportUnusedOld);
- }
- function exportUnusedOld() {
- var win = window.open("", "Groupees Keys Export", "width=480,height=640");
- $(".code:not([disabled])").each(function() {
- if (markUsed) $(this).parents(".product").find(".usage").click();
- win.document.write($(this).parents(".product").find("h3").text() + keySeparator + (keyOnNewLine ? "<br>" : "") + $(this).val() + (addWhiteLine ? "<br><br>" : "<br>"));
- });
- selectAll(win);
- }
- function selectAll(win) {
- var range = win.document.createRange();
- range.selectNodeContents(win.document.body);
- var selection = win.window.getSelection();
- selection.removeAllRanges();
- selection.addRange(range);
- }
- function SortByGame(a, b){
- var aName = a.game.toLowerCase();
- var bName = b.game.toLowerCase();
- return ((aName < bName) ? -1 : ((aName > bName) ? 1 : 0));
- }