SHARE
TWEET

Untitled

a guest Jan 24th, 2020 287 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name        Steam JS fix
  3. // @version     10
  4. // @author      Bladru
  5. // @description Patches unsupported syntax
  6. // @include     *://store.steampowered.com/*
  7. // @include     *://steamcommunity.com/*
  8. // ==/UserScript==
  9.  
  10. /*
  11. Opera only. Save as "Steam_js_fix.js" (without .user).
  12. */
  13.  
  14. (function(){
  15.  
  16. window.opera.addEventListener("BeforeScript", patch_scripts);
  17. function patch_scripts(UserJSEvent){
  18.     var script = UserJSEvent.element;
  19.    
  20.     var regex_let = /\b(let|const)\s/g;
  21.     var str_var = "var ";
  22.    
  23.     var for_of = "for ( var mutation of mutationsList )";
  24.     var for_in = "for ( var mutation in mutationsList )";
  25.    
  26.     var regex_for_of = /for\s*\(\s*((?:var )?[\w$]+) of ([\w$.]+)\s*\)\s*{/;
  27.     var patched_for_of = "for ( var i_fix in $2 ) { $1 = $2[i_fix];";
  28.    
  29.     var regex_function_el = /AddSNRDepthParamsToCapsuleList\( \$Capsules \)\s+{/;
  30.     var patched_function_el = "AddSNRDepthParamsToCapsuleList: function( $Capsules ){";
  31.    
  32.     if ((script.src.indexOf("/gamehighlightplayer.js") != -1
  33.     || script.src.indexOf("/main.js") != -1
  34.     || script.src.indexOf("/salefunctions.js") != -1
  35.     || script.src.indexOf("/shared_global.js") != -1
  36.     || script.src.indexOf("/home.js") != -1
  37.     ) && regex_let.test(script.text)){
  38.         script.text = script.text.replace(regex_let, str_var);
  39.         console.log("'let|const' statement replaced with 'var' in " + script.src);
  40.     }
  41.    
  42.     if (script.src.indexOf("/shared_global.js") != -1 && script.text.indexOf(for_of) != -1){
  43.         /* patched function throws exception either way */
  44.         script.text = script.text.replace(for_of, for_in);
  45.         console.log("'for .. of' statement replaced with 'for .. in' in " + script.src);
  46.     }
  47.     else if ((script.src.indexOf("/registerkey.js") != -1
  48.     || script.src.indexOf("/searchpage.js") != -1
  49.     || script.src.indexOf("/home.js") != -1
  50.     ) && regex_for_of.test(script.text)){
  51.         script.text = script.text.replace(regex_for_of, patched_for_of);
  52.         console.log("'for .. of' statement replaced with 'for .. in' in " + script.src);
  53.     }
  54.     else if (script.src.indexOf("/dynamicstore.js") != -1 && regex_function_el.test(script.text)){
  55.         script.text = script.text.replace(regex_function_el, patched_function_el);
  56.         console.log("AddSNRDepthParamsToCapsuleList declaration fixed in " + script.src);
  57.     }
  58.     else if (script.src.indexOf("/game.js") != -1){
  59.         script.text = script.text.replace("console.log( `#${i}", "//console.log( `#${i}");
  60.     }
  61. }
  62.  
  63. })();
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top