WaterlooWorks Plus

A little script to patch some of the UI atrocities that exist in WaterlooWorks. Contribute at github.com/Jaribeau/waterloo-works-plus

目前為 2017-01-19 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         WaterlooWorks Plus
// @namespace    http://jareds.site/
// @version      1.2
// @description  A little script to patch some of the UI atrocities that exist in WaterlooWorks. Contribute at github.com/Jaribeau/waterloo-works-plus
// @author       Jared Baribeau
// @match        https://waterlooworks.uwaterloo.ca/myAccount/co-op/coop-postings.htm
// @grant        none
// ==/UserScript==

function fixUI() {
    'use strict';

    // Remove the massive sidebar
    $(".span2").remove();
    $(".row-fluid .span10").css("width", "100%");  // Expand the table to fill the newly obtained space
    
    // Shrink the '# of apps' columns
    var numAppsHeader = $("a:contains(Students' Applications)");
    if (numAppsHeader[0]){
        numAppsHeader[0].innerHTML = "# Apps";
    }
    
    // Change text wrap settings for various columns
    $(function() {
        $("tbody td").each(function (index, value) {
            $(this).css('white-space', ['nowrap', 'nowrap', 'nowrap', 'pre-wrap', 'pre-wrap', 'pre-wrap','pre-wrap','pre-wrap','pre-wrap','pre-wrap','','',''][index % 13]); // Where there are 13 columns, and each corresponds
        });
    });
    
    // Resize "Remove from shortlist" button to match the add button
    $(function() {
        jQuery.each($("a.favourite:contains(Remove from shortlist)"), function(index, value) {
            if(value) {
                value.innerHTML = "Remove";
            }
        }).css("background-color", "orange");
    });

    // Function to rearrange table columns
    jQuery.moveColumn = function (table, fromIndex, toIndex) {
        var rows = jQuery('tr', table);
        var cols;
        rows.each(function() {
            cols = jQuery(this).children('th, td');
            cols.eq(fromIndex).detach().insertBefore(cols.eq(toIndex));
        });
    };
    
    // Rearrang the table columns as desired
    var tbl = jQuery('table');
    jQuery.moveColumn(tbl, 12, 1); // Moves 'Not Interested' button to second column
    jQuery.moveColumn(tbl, 2, 13); // Moves job ID to the very end

};

//Make sure you're on the search results page
if ($('h1:contains(Search Results)')[0]){

    //Run script once on load, then again when user clicks any link (except for "Not Interested")
    fixUI();
    $(document).on('click', 'a:not(:has(img[title="Not Interested"]))', function() {
            // TODO: Make this smarter to eliminate race condition
            setTimeout(fixUI, 700); // Delay while the table content is updated
    });
}