Tuesday, 21 June 2016

Greasemonkey/Tampermonkey to remove certain rows from a html table

// ==UserScript==
// @name         ModifyUFCPageOnlyUltimateClasses
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        http://www.ufcgymsydney.com/home/programming/class_schedule.aspx
// @grant        none
// @require      http://code.jquery.com/jquery-latest.js
// ==/UserScript==


//===================================================================================
function ShowOrHideOthers(strShowOrHide) {

var tableOfClasses = document.getElementById('ctl00_phBody_gvClasses');


    if (strShowOrHide == "hide") {
        strDisplay="none";
    } else {
      strDisplay= "block";
       alert("will show em");
    }
   
var intPosOfClassType=3;
  // loop through all rows in the class table - start at row 2
 for(var i=2; i
        // FIX THIS
     try {
        var strClassType=(tableOfClasses.rows[i].cells[intPosOfClassType].innerHTML);                
        if (strClassType!="Ultimate") {          
            //alert(strClassType);
            tableOfClasses.rows[i].style.display = strDisplay;
        } // alert for ultimate classes
             }
     catch(err) {    
         // this is if we can't read the innerHTML of rows with only 1 cell... ignore it. alert(err.message);    
     }
 } // for each row

}
 // end function show or hide others
//===================================================================================

if (confirm("Would you like to only show ultimate classes (tampermonkey script by atk)") === true) {
  ShowOrHideOthers("hide");  
}







No comments: