Greasy Fork

Greasy Fork is available in English.

Import/Export Steam Ignore List

Imports/Exports Steam Ignore List

当前为 2018-02-25 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        Import/Export Steam Ignore List
// @language    English
// @namespace   http://greasyfork.icu/users/2205
// @description Imports/Exports Steam Ignore List
// @include     https://store.steampowered.com/account/notinterested/*
// @include     http://store.steampowered.com/account/notinterested/*
// @version     1.1
// @grant       none
// ==/UserScript==

var RateLimiterPost = function(url, postParams, successCallback, failCallback) {
  var Rate=30; //ms between requests;
    var lastCall=localStorage.getItem ('IESIIRateLimiter');
    if (lastCall!=null) {
      if ((parseInt(lastCall) + Rate) > Date.now()) {
        window.setTimeout(function(){
          RateLimiterPost(url, postParams, successCallback, failCallback);
        },parseInt(lastCall)+Rate-Date.now());
      } else { //already time
        $J.post(url, postParams, successCallback).fail(failCallback);
        localStorage.setItem('IESIIRateLimiter',Date.now());
      }
    }  else { //first call ever
      $J.post(url, postParams, successCallback).fail(failCallback);
      localStorage.setItem('IESIIRateLimiter',Date.now());
    }
};


var anchor = document.getElementsByClassName("ignoredapps")[0];
var workingDialog;
//Export
var ExportBtn=document.createElement("div");
ExportBtn.setAttribute("class","btn_darkblue_white_innerfade btn_medium");
ExportBtn.setAttribute("style","margin-right: 5px !important;");
ExportBtn.appendChild(document.createElement("span"));
ExportBtn.firstChild.appendChild(document.createTextNode("Export"));
var newExportBtn=anchor.parentElement.insertBefore(ExportBtn,anchor);
newExportBtn.addEventListener("click",function(){
  $J.get("/dynamicstore/userdata/", {t: new Date().getTime()}, function(data) {
  var strdata=data.rgIgnoredApps.toString();
  var exportDialog=ShowAlertDialog("Ignore List", '<div class="bb_code">'+strdata.replace(/\,/g, ",<br />")+'</div>', "OK");

},"json").fail(function() {
ShowAlertDialog("Export Error","There was an error retrieving ignore list","OK");
});
});

//Import
var ImportBtn=document.createElement("div");
ImportBtn.setAttribute("class","btn_darkblue_white_innerfade btn_medium");
ImportBtn.setAttribute("style","margin-right: 5px !important;");
ImportBtn.appendChild(document.createElement("span"));
ImportBtn.firstChild.appendChild(document.createTextNode("Import"));
var newImportBtn=anchor.parentElement.insertBefore(ImportBtn,anchor);
var successfull=0;
var failed=0;
var totalitems;
newImportBtn.addEventListener("click",function(){
  importDialog=ShowPromptWithTextAreaDialog( "Import Ignore List", "", "OK", "Cancel", 32765 ).done( function(newIgnoreListText){
   if (/^[0-9]+(,\s*[0-9]+)*$/.test(newIgnoreListText)) {
     var IgnoreListTextItems=newIgnoreListText.split(",");
     successfull=0;
     failed=0;
     totalitems=IgnoreListTextItems.length;
     workingDialog = ShowBlockingWaitDialog( 'Import Ingnore List', 'Please wait, ' + totalitems +' entries left' );
     for (var i=0; i<totalitems;i++){
       ignoreitem=parseInt(IgnoreListTextItems[i].trim());
       if (ignoreitem===0){
         continue; //Dunno why this can even happen, but still
       }
       RateLimiterPost('/recommended/ignorerecommendation/', {
         sessionid: g_sessionID,
	       appid: ignoreitem,
	       add: 1
         }, function() {
               successfull++;
                if ((successfull+failed)===totalitems) {
                  workingDialog.Dismiss();
                  ShowAlertDialog( "Import", "Import Finished.<br />Press \"OK\" to reload page.", "OK" ).done(function(){
                      window.location.reload();
                    });
                } else {
                    workingDialog.Dismiss();
                    workingDialog = ShowBlockingWaitDialog( 'Import Ingnore List', 'Please wait, ' + (totalitems-successfull-failed) +' entries left' );
                }
            }, function() {
               failed++;
                if ((successfull+failed)===totalitems) {
                  workingDialog.Dismiss();
                  ShowAlertDialog( "Import", "Import Finished.<br />Press \"OK\" to reload page.", "OK" ).done(function(){
                      window.location.reload();
                    });
                } else {
                    workingDialog.Dismiss();
                    workingDialog = ShowBlockingWaitDialog( 'Import Ingnore List', 'Please wait, ' + (totalitems-successfull-failed) +' entries left' );
                }
            });
     }
   } else {
     ShowAlertDialog( "Import Error", "Wrong list syntax!", "OK" );
   }
  });
});


var ClearBtn=document.createElement("div");
ClearBtn.setAttribute("class","btn_darkblue_white_innerfade btn_medium");
ClearBtn.setAttribute("style","margin-right: 5px !important;");
ClearBtn.appendChild(document.createElement("span"));
ClearBtn.firstChild.appendChild(document.createTextNode("Clear"));
var newClearBtn=anchor.parentElement.insertBefore(ClearBtn,anchor);
newClearBtn.addEventListener("click",function(){
  ShowConfirmDialog( "Clear Ignore List", "Are you sure you want to clear ignore list?", "Yes", "No").done(function(){
  $J.get("/dynamicstore/userdata/", {t: new Date().getTime()}, function(data) {
     successfull=0;
     failed=0;
     totalitems=data.rgIgnoredApps.length;
     workingDialog = ShowBlockingWaitDialog( 'Clear Ingnore List', 'Please wait, ' + totalitems +' entries left' );
     for (var j=0;j<totalitems;j++){
       RateLimiterPost('/recommended/ignorerecommendation/', {sessionid: g_sessionID,
                appid: data.rgIgnoredApps[j],
                remove: 1}, function () {
         successfull++;
         if ((successfull+failed)===totalitems) {
                  if (failed>0){
                    workingDialog.Dismiss();
                    ShowAlertDialog( "Clear", "Cleanup finished, unable to remove "+failed+" items.<br />Press \"OK\" to reload page.", "OK" ).done(function(){
                      window.location.reload();
                    });
                  } else {
                    workingDialog.Dismiss();
                    ShowAlertDialog( "Clear", "Ignore list cleared successfuly<br />Press \"OK\" to reload page.", "OK" ).done(function(){
                      window.location.reload();
                    });
                  }
                } else {
                    workingDialog.Dismiss();
                    workingDialog = ShowBlockingWaitDialog( 'Clear Ingnore List', 'Please wait, ' + (totalitems-successfull-failed) +' entries left' );
                }
       }, function(){
        failed++;
               if ((successfull+failed)===totalitems) {
                    workingDialog.Dismiss();
                    ShowAlertDialog( "Clear", "Cleanup finished, unable to remove "+failed+" items.<br />Press \"OK\" to reload page.", "OK" ).done(function(){
                      window.location.reload();
                    });

                } else {
                    workingDialog.Dismiss();
                    workingDialog = ShowBlockingWaitDialog( 'Clear Ingnore List', 'Please wait, ' + (totalitems-successfull-failed) +' entries left' );
                }
       });
     }
},"json").fail(function() {
ShowAlertDialog("Clean Error","There was an error retrieving ignore list","OK");
});

  });
});