vulkan plan filter

Filter your plan in vulkan by subject groups

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name     vulkan plan filter
// @version  0.2.0
// @grant    none
// @match http://www.batory.edu.pl/plan/*/index.html
// @match http://www.batory.edu.pl/plan/*/plany/o*.html
// @namespace https://greasyfork.org/users/853831
// @description Filter your plan in vulkan by subject groups
// ==/UserScript==


// config
let groups = {
  "MAT": 2,
  "GR3": 3,
  "GR4": 3,
  "GR6": 2,
  "POL": 1,
  "ENG": 3,
  "TOK": 3,
  "WF": 3,
  "GW": 2,
  "CAS": 2,
};

console.log("plan filter");

window.addEventListener("load", LocalMain, false);

function LocalMain () {
  let plan_window = null;
  if (document.URL.includes("plany")) {
    plan_window = window;
  } else {
  	plan_window = window.frames[1];
  }
  console.log(window);
  
  let cells = plan_window.document.querySelectorAll(".l");
//   console.log(cells);

  for (i=0; i<cells.length; i++) {    
    let children = cells[i].children; 
//     console.log(children);
    
    for (j=0; j<children.length; j++) {
      if (children[j].localName === "br") {
        continue;
      }
      
     	let text = children[j].children[0].innerText;
      
      let subject = text.split("-")[0];
      let group = text.split("-")[1].split("/")[0];
      
//       console.log(subject);
//       console.log(group);
      
      if (groups[subject] && groups[subject] != group) {
        children[j].innerText = "";
      }
    }
  }
  
  console.log("cleared plan");
}