Beridok

HLTB Steam Import "Selecter"

Jul 9th, 2020
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Put game list as groups (doesn't have to be like this, can be one long string separating each title with same character, e.g. comma+spacebar [although some silly games use that in their names] - this will require to mild adaptation of code)
  2. var group1 = ["1954 Alcatraz", "90 Minute Fever"];
  3. var group2 = ["200% Mixed Juice!", "60 Parsecs!"];
  4. var group3 = ["A New Beginning - Final Cut", "A Space For The Unbound - Prologue"];
  5. var group4 = [];
  6. var group5 = [];
  7. var group6 = [];
  8. var group7 = [];
  9. var group8 = [];
  10.  
  11. var colorMe = true; //if games without choices should have background color changed...
  12. var theColor = "darkred"; //color to change div... (row in table)
  13.  
  14. var count = document.querySelector('.steam_table > tbody:nth-child(2)').children.length; //Get number of games to import...
  15. for ( let i = 1; i <= count; i++ )
  16. {
  17.     var option = null; //Option default - we are going to replace it with rules below...
  18.     var gameName = document.querySelector('tr.spreadsheet:nth-child('+i+') > td:nth-child(1)').textContent; //Get game's name from table...
  19.     var playTime = document.querySelector('tr.spreadsheet:nth-child('+i+') > td:nth-child(2)').textContent.trim();
  20.     //No play time gives this string: "--"
  21.    
  22.     document.querySelector('tr.spreadsheet:nth-child('+i+')').style.backgroundColor = ""; //Reset color (just in case it was changed before);
  23.    
  24.     if ( group1.indexOf(gameName) > -1 ) { option = 1 } //check if game's name is in group1 of games, if it is, assign this game to group1 - aka it will select first option on list (Playing)
  25.     else if ( group2.indexOf(gameName) > -1 ) { option = 2 } //Backlog
  26.     else if ( group3.indexOf(gameName) > -1 ) { option = 3 } //Replay
  27.     else if ( group4.indexOf(gameName) > -1 ) { option = 4 } //Custom Tab 1 [MPOnline for me]
  28.     else if ( group5.indexOf(gameName) > -1 ) { option = 5 } //Custom Tab 2 [VR for me]
  29.     else if ( group6.indexOf(gameName) > -1 ) { option = 6 } //Custom Tab 3 [CustomTab for me]
  30.     else if ( group7.indexOf(gameName) > -1 ) { option = 7 } //Completed
  31.     else if ( group8.indexOf(gameName) > -1 ) { option = 8 } //Retired
  32.     else {
  33.         option = 0;
  34.         console.log(gameName+" can't be detected in any groups.");
  35.         if ( colorMe === true ) {
  36.             document.querySelector('tr.spreadsheet:nth-child('+i+')').style.backgroundColor = theColor; //changing color
  37.         }
  38.     }
  39.    
  40.     //Custom rules here. Put any number you want instead of "number". E.g. for rule with VR, I would use my custom tab 2, which is option 5.
  41.     //Example 1, if time is empty
  42.     //if ( playTime === "--" ) { option = number }
  43.    
  44.     //Example 2, if time is not empty...
  45.     //if ( playTime.length > 2 ) { option = number }
  46.    
  47.     //Example 3, if game has "VR" in name (case-sensitive)
  48.     //if ( gameName.indexOf("VR") > -1 ) { option = number }
  49.  
  50.     document.querySelector('tr.spreadsheet:nth-child('+i+') > td:nth-child(3) > select:nth-child(1)').selectedIndex = option;
  51. }
Add Comment
Please, Sign In to add comment