Instantly share code, notes, and snippets.
Last active
January 28, 2016 22:13
-
Star
0
(0)
You must be signed in to star a gist -
Fork
0
(0)
You must be signed in to fork a gist
-
-
Save jadkik/52db71fba63bee0007f5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name aub-banner | |
| // @namespace aub-banner | |
| // @description aub banner | |
| // @include https://www-banner.aub.edu.lb/pls/* | |
| // @version 1.1 | |
| // @grant none | |
| // @require https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js | |
| // @require https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js | |
| // ==/UserScript== | |
| // function to inject js to the DOM | |
| function inject(id, jscode) { | |
| var injscript = document.createElement('script'); | |
| injscript.setAttribute("id", id); | |
| injscript.setAttribute("type", "text/javascript"); | |
| injscript.appendChild(document.createTextNode('('+ jscode +')();')); | |
| (document.body || document.head || document.documentElement).appendChild(injscript); | |
| } | |
| function injmain() | |
| { | |
| function getCSSRule(ruleName, deleteFlag, mediaSelect) { // Return requested style obejct | |
| ruleName=ruleName.toLowerCase(); // Convert test string to lower case. | |
| if (document.styleSheets) { // If browser can play with stylesheets | |
| for (var i=0; i<document.styleSheets.length; i++) { // For each stylesheet | |
| var styleSheet=document.styleSheets[i]; // Get the current Stylesheet | |
| if (styleSheet.id == 'thepotato' | |
| || (styleSheet.href && styleSheet.href.lastIndexOf("https://www-banner.aub.edu.lb/", 0) !== 0)) { | |
| console.log("Skip stylesheet", styleSheet.id, styleSheet.href, styleSheet.media); | |
| continue; | |
| } | |
| if (mediaSelect !== undefined && styleSheet.media[0] != mediaSelect) { | |
| console.log("Skip stylesheet", styleSheet.id, styleSheet.href, styleSheet.media); | |
| continue; | |
| } | |
| console.log("Looking at", styleSheet); | |
| var ii=0; // Initialize subCounter. | |
| var cssRule=false; // Initialize cssRule. | |
| do { // For each rule in stylesheet | |
| if (styleSheet.cssRules) { // Browser uses cssRules? | |
| cssRule = styleSheet.cssRules[ii]; // Yes --Mozilla Style | |
| } else { // Browser usses rules? | |
| cssRule = styleSheet.rules[ii]; // Yes IE style. | |
| } // End IE check. | |
| if (cssRule && cssRule.selectorText) { // If we found a rule... | |
| if (cssRule.selectorText.toLowerCase()==ruleName) { // match ruleName? | |
| if (deleteFlag=='delete') { // Yes. Are we deleteing? | |
| if (styleSheet.cssRules) { // Yes, deleting... | |
| styleSheet.deleteRule(ii); // Delete rule, Moz Style | |
| } else { // Still deleting. | |
| styleSheet.removeRule(ii); // Delete rule IE style. | |
| } // End IE check. | |
| return true; // return true, class deleted. | |
| } else { // found and not deleting. | |
| return cssRule; // return the style object. | |
| } // End delete Check | |
| } // End found rule name | |
| } else if (cssRule && cssRule.cssRules) { // end found cssRule | |
| var jj=0; | |
| var cssChildRule=false; | |
| do { | |
| if (cssRule.cssRules) { // Browser uses cssRules? | |
| cssChildRule = cssRule.cssRules[jj]; // Yes --Mozilla Style | |
| } else { // Browser usses rules? | |
| cssChildRule = cssRule.rules[jj]; // Yes IE style. | |
| } | |
| if (cssChildRule.selectorText.toLowerCase()==ruleName) { // match ruleName? | |
| if (deleteFlag=='delete') { // Yes. Are we deleteing? | |
| if (cssRule.cssRules) { // Yes, deleting... | |
| cssRule.deleteRule(jj); // Delete rule, Moz Style | |
| } else { // Still deleting. | |
| cssRule.removeRule(jj); // Delete rule IE style. | |
| } // End IE check. | |
| return true; // return true, class deleted. | |
| } else { // found and not deleting. | |
| return cssChildRule; // return the style object. | |
| } // End delete Check | |
| } | |
| jj++; | |
| } while (cssChildRule); | |
| } | |
| ii++; // Increment sub-counter | |
| } while (cssRule) // end While loop | |
| } // end For loop | |
| } // end styleSheet ability check | |
| return false; // we found NOTHING! | |
| } // end getCSSRule | |
| function killCSSRule(ruleName, mediaSelect) { // Delete a CSS rule | |
| return getCSSRule(ruleName,'delete', mediaSelect); // just call getCSSRule w/delete flag. | |
| } // end killCSSRule | |
| function addCSSRule(ruleName) { // Create a new css rule | |
| if (document.styleSheets) { // Can browser do styleSheets? | |
| if (!getCSSRule(ruleName)) { // if rule doesn't exist... | |
| if (document.styleSheets[0].addRule) { // Browser is IE? | |
| document.styleSheets[0].addRule(ruleName, null,0); // Yes, add IE style | |
| } else { // Browser is IE? | |
| document.styleSheets[0].insertRule(ruleName+' { }', 0); // Yes, add Moz style. | |
| } // End browser check | |
| } // End already exist check. | |
| } // End browser ability check. | |
| return getCSSRule(ruleName); // return rule we just created. | |
| } | |
| function addGlobalStyleFile(url, media, callback) | |
| { | |
| // adding the script tag to the head as suggested before | |
| var head = document.getElementsByTagName('head')[0]; | |
| var link = document.createElement('link'); | |
| link.type = 'text/css'; | |
| link.rel = 'stylesheet'; | |
| link.href = url; | |
| link.media = media; | |
| // then bind the event to the callback function | |
| // there are several events for cross browser compatibility | |
| if (callback) { | |
| link.onreadystatechange = callback; | |
| link.onload = callback; | |
| } | |
| // fire the loading | |
| head.appendChild(link); | |
| }; | |
| function addGlobalStyle(css, media) { | |
| try { | |
| var elmHead, elmStyle; | |
| elmHead = document.getElementsByTagName('head')[0]; | |
| elmStyle = document.createElement('style'); | |
| elmStyle.type = 'text/css'; | |
| elmStyle.id = 'thepotato'; | |
| elmStyle.media = media; | |
| elmHead.appendChild(elmStyle); | |
| elmStyle.innerHTML = css; | |
| } catch (e) { | |
| if (!document.styleSheets.length) { | |
| document.createStyleSheet(); | |
| } | |
| document.styleSheets[0].cssText += css; | |
| } | |
| } | |
| //////////////////////////////////////////////////////////////////// | |
| function stylize() { | |
| var MINIFIED_CSS = "body{background-image:none}div.headerwrapperdiv{background-color:#fff;background-image:url(https://www-banner.aub.edu.lb/wtlgifs/web_bg_app.jpg);background-position:-440px 0;background-repeat:no-repeat;padding-top:100px;padding-bottom:10px;border-bottom:solid 2px #ccc}div.headerwrapperdiv div.pageheaderdiv1,div.pagetitlediv{display:none}div.pagebodydiv{padding-top:10px}div.links-container>div a{margin-top:75px}div.links-container>div{height:200px;background-color:#fff;text-align:center}div.infotextdiv{max-width:80%;padding:.5em;margin-top:.5em;margin-bottom:.5em}html body div.pagefooterdiv{border-top:solid 2px #ccc;padding-top:10px;float:none;clear:both}div.dropdown-menu-btn{margin:0 10px}"; | |
| var cacheBust = (new Date()).getTime(); | |
| addGlobalStyleFile('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css', 'screen'); | |
| addGlobalStyleFile('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css', 'screen'); | |
| //~ addGlobalStyleFile('http://localhost/aub-banner-style.css?' + cacheBust, 'screen'); | |
| addGlobalStyle(MINIFIED_CSS, 'screen'); | |
| } | |
| function header() { | |
| var $headerlinks = $("html body div.headerwrapperdiv div.headerlinksdiv span.pageheaderlinks2 map table.plaintable tbody tr td.pldefault table.plaintable tbody tr td"); | |
| var $nav = $('<ul class="nav nav-pills col-md-8"></ul>'); | |
| $headerlinks.each(function() { | |
| var $td = $(this); | |
| var tabon = $td.hasClass("tabon"); | |
| var taboff = $td.hasClass("taboff"); | |
| if (!tabon && !taboff) { | |
| return; | |
| } | |
| var $li = $("<li></li>"); | |
| var $a = $('<a></a>'); | |
| var $olda = $td.children("a:first"); | |
| $a.attr("href", $olda.attr("href")); | |
| $a.attr("title", $olda.text()); | |
| $a.text($olda.text()); | |
| if (tabon) { | |
| $li.addClass("active"); | |
| } | |
| $li.append($a); | |
| $nav.append($li); | |
| }); | |
| $(".headerlinksdiv").html(""); | |
| $(".headerlinksdiv").append($nav); | |
| // Search and action links | |
| var $searchtable = $("html body div.headerwrapperdiv > table.plaintable"); | |
| var $searchdiv = $searchtable.find("tbody > tr > td > div.headerlinksdiv2"); | |
| var $searchlinks = $searchtable.find("tbody > tr > td > span.pageheaderlinks"); | |
| $searchdiv.addClass("col-md-4 text-right"); | |
| var $searchform = $searchdiv.children("form"); | |
| $searchform.html('<div class="form-group"><label for="keyword_in_id">Search</label> <input class="form-control input-sm" name="KEYWRD_IN" size="20" maxlength="65" id="keyword_in_id" type="text"></div> <input class="btn btn-default btn-sm" value="Go" type="submit"> '); | |
| $searchform.addClass("form-inline pull-right"); | |
| var $newlinks = $("<div></div>"); | |
| var $dropdown = $('<ul class="dropdown-menu"></ul>'); | |
| $newlinks.addClass("btn-group btn-group-sm dropdown-menu-btn"); | |
| $newlinks.append('<button type="button" class="btn btn-success dropdown-toggle pull-right" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Menu <span class="caret"></span></button>'); | |
| //~ $searchlinks.find("a").addClass("btn btn-default btn-sm"); | |
| $searchlinks.children("a").each(function() { | |
| var $li = $('<li></li>'); | |
| $li.append($(this).clone()); | |
| $dropdown.append($li); | |
| }); | |
| $newlinks.append($dropdown); | |
| $searchdiv.append($newlinks); | |
| $searchdiv.appendTo($(".headerlinksdiv")); | |
| $searchdiv.removeClass("headerlinksdiv2"); | |
| $searchtable.remove(); | |
| $("html body div.headerwrapperdiv").addClass("clearfix"); | |
| } | |
| function body() { | |
| var $table = $("html body div.pagebodydiv table.menuplaintable"); | |
| var $links = $('<div class="container links-container"></div>'); | |
| $table.find("tbody tr").each(function(i, el1) { | |
| var text = ""; | |
| var $lasta; | |
| $(el1).find('td.mpdefault a').each(function(j, el2) { | |
| text += $(el2).text(); | |
| $lasta = $(el2); | |
| }); | |
| var $item = $('<div class="col-md-4 menu-item"></div>'); | |
| var $a = $lasta.clone(); | |
| $a.removeClass("submenulinktext2"); | |
| $a.addClass("btn btn-default btn-lg"); | |
| if (text != "") { | |
| $a.text(text); | |
| } | |
| $item.append($a); | |
| $links.append($item); | |
| }); | |
| $table.replaceWith($links); | |
| // line separator | |
| $('html body div.pagebodydiv > table.plaintable[summary="This is table displays line separator at end of the page."]').remove(); | |
| $('div.pagebodydiv').addClass("container"); | |
| } | |
| function footer() { | |
| var $t = $("html body div.pagefooterdiv span.releasetext"); | |
| var t = $t.text(); | |
| $t.text(t + "mod"); | |
| } | |
| function loginForm() { | |
| var $form = $("form[name=loginform]"); | |
| if (!$form || $form.length == 0) { | |
| return; | |
| } | |
| console.log('Found the login form', $form); | |
| var $userid = $('<div class="form-group">'); | |
| $userid.append($form.find("label[for=UserID]")); | |
| $userid.append($form.find("input[name=sid]")); | |
| var $pin = $('<div class="form-group">'); | |
| $pin.append($form.find("label[for=PIN]")); | |
| $pin.append($form.find("input[name=PIN]")); | |
| var $btns = $form.find('input[type=submit]'); | |
| $form.append($userid); | |
| $form.append($pin); | |
| $btns.each(function(i, el) { | |
| var $el = $(el); | |
| if (i == 0) { | |
| $el.addClass("btn btn-primary"); | |
| } else { | |
| $el.addClass("btn btn-default"); | |
| } | |
| $form.append($el); | |
| $form.append(" "); | |
| }); | |
| $form.find('input[type=text],input[type=password]').addClass('form-control'); | |
| $form.children('p,table').remove(); | |
| var $container = $('<div class="form-container clearfix">'); | |
| var $center = $('<div class="col-md-4 col-md-push-4">'); | |
| var $panel = $('<div class="panel panel-default"></div>'); | |
| $panel.append('<div class="panel-heading"><h3 class="panel-title">Login to AUB SIS</h3></div>'); | |
| var $body = $('<div class="panel-body">'); | |
| $center.append($panel); | |
| $container.append($center); | |
| $panel.append($body); | |
| $container.insertAfter($form); | |
| $form.appendTo($body); | |
| $("div.infotextdiv").each(function(i, el) { | |
| $(el).insertAfter($container); | |
| }); | |
| } | |
| function selectTermForm() { | |
| var $form = $("form:has(table.dataentrytable[summary='This table allows\n" + | |
| " the user to select a\n" + | |
| " valid term for\n" + | |
| " registration\n" + | |
| " processing.'])"); | |
| if (!$form || $form.length == 0) { | |
| return; | |
| } | |
| console.log("Found select term form:", $form); | |
| var $select = $form.find("select[name=term_in]"); | |
| var $userid = $('<div class="form-group">'); | |
| $userid.append($('<label for="term_id"></label>').text($form.find("td.delabel").text())); | |
| $userid.append($select); | |
| var $btns = $form.find('input[type=submit]'); | |
| $form.append($userid); | |
| $btns.each(function(i, el) { | |
| var $el = $(el); | |
| if (i == 0) { | |
| $el.addClass("btn btn-primary"); | |
| } else { | |
| $el.addClass("btn btn-default"); | |
| } | |
| $form.append($el); | |
| $form.append(" "); | |
| }); | |
| $select.find('option').each(function() { | |
| if ($(this).prop('selected')) { | |
| return; | |
| } | |
| var text = $(this).text().trim(); | |
| if (text.lastIndexOf('Spring', 0) === 0 || text.lastIndexOf('Fall', 0) === 0) { | |
| $(this).prop('selected', true); | |
| return false; | |
| } | |
| }); | |
| $form.find('select').addClass('form-control'); | |
| $form.children('p,table').remove(); | |
| var $container = $('<div class="form-container clearfix">'); | |
| var $center = $('<div class="col-md-4 col-md-push-4">'); | |
| var $panel = $('<div class="panel panel-default"></div>'); | |
| //~ $panel.append('<div class="panel-heading"><h3 class="panel-title">Login to AUB SIS</h3></div>'); | |
| var $body = $('<div class="panel-body">'); | |
| $center.append($panel); | |
| $container.append($center); | |
| $panel.append($body); | |
| $container.insertAfter($form); | |
| $form.appendTo($body); | |
| $("div.infotextdiv").each(function(i, el) { | |
| $(el).insertAfter($container); | |
| }); | |
| } | |
| function otherSelectTermForm() { | |
| var $form = $("form:has(table.dataentrytable[summary='This layout table is used for term selection.'])"); | |
| if (!$form || $form.length == 0) { | |
| return; | |
| } | |
| console.log("Found other select term form:", $form); | |
| var $select = $form.find("select[name=p_term]"); | |
| var $userid = $('<div class="form-group">'); | |
| $userid.append($('<label for="term_input_id"></label>').text($form.find("caption.captiontext").text())); | |
| $userid.append($select); | |
| var $btns = $form.find('input[type=submit],input[type=reset]'); | |
| $form.append($userid); | |
| $btns.each(function(i, el) { | |
| var $el = $(el); | |
| if (i == 0) { | |
| $el.addClass("btn btn-primary"); | |
| } else { | |
| $el.addClass("btn btn-default"); | |
| } | |
| $form.append($el); | |
| $form.append(" "); | |
| }); | |
| $select.find('option').each(function() { | |
| if ($(this).prop('selected')) { | |
| return; | |
| } | |
| var text = $(this).text().trim(); | |
| if (text.lastIndexOf('Spring', 0) === 0 || text.lastIndexOf('Fall', 0) === 0) { | |
| $(this).prop('selected', true); | |
| return false; | |
| } | |
| }); | |
| $form.find('select').addClass('form-control'); | |
| $form.children('p,table,br').remove(); | |
| var $container = $('<div class="form-container clearfix">'); | |
| var $center = $('<div class="col-md-4 col-md-push-4">'); | |
| var $panel = $('<div class="panel panel-default"></div>'); | |
| //~ $panel.append('<div class="panel-heading"><h3 class="panel-title">Login to AUB SIS</h3></div>'); | |
| var $body = $('<div class="panel-body">'); | |
| $center.append($panel); | |
| $container.append($center); | |
| $panel.append($body); | |
| $container.insertAfter($form); | |
| $form.appendTo($body); | |
| $("div.infotextdiv").each(function(i, el) { | |
| $(el).insertAfter($container); | |
| }); | |
| } | |
| function removeOnSubmit() { | |
| var $forms = $('form[onsubmit="return checkSubmit()"]'); | |
| console.log("on submit, changes already submitted", $forms); | |
| $forms.attr('onsubmit', ''); | |
| } | |
| function mainMenu() { | |
| $('img[name=Moodle-Item]').replaceWith('Moodle at AUB'); | |
| //~ $('img[name=StuWeb-MainMenuLink]').replaceWith('Student Services and Financial Aid'); | |
| $('img[name=StuWeb-MainMenuLink]').parents(".menu-item").remove(); | |
| $('img[name=complaint_suggestion]').replaceWith('Suggestions/Complaints'); | |
| //~ $('img[name=GeneralClosedFileCabinet]').replaceWith('Personal Information'); | |
| $('img[name=GeneralClosedFileCabinet]').parents(".menu-item").remove(); | |
| } | |
| function augmentNavMenu() { | |
| var $student_services = $("ul.nav").children('li:nth-child(2)'); | |
| $student_services.attr("role", "presentation"); | |
| $student_services.addClass("dropdown"); | |
| var $a = $student_services.children('a'); | |
| $a.addClass("dropdown-toggle"); | |
| $a.attr('data-toggle', 'dropdown'); | |
| var href = $a.attr('href'); | |
| $a.attr('role', 'button'); | |
| $a.attr('aria-haspopup', 'true'); | |
| $a.attr('aria-expanded', 'false'); | |
| $a.append('<span class="caret"></span>'); | |
| $student_services.append('<ul class="dropdown-menu">'); | |
| var $ul = $student_services.children('ul'); | |
| $ul.append('<li><a href="' + href + '">Services</a></li>'); | |
| $ul.append('<li role="separator" class="divider"></li>'); | |
| $ul.append('<li><a href="/pls/weba/twbkwbis.P_GenMenu?name=bmenu.P_RegMnu">Registration</a></li>'); | |
| $ul.append('<li><a href="/pls/weba/twbkwbis.P_GenMenu?name=bmenu.P_AdminMnu">Student Records</a></li>'); | |
| } | |
| function augmentCourseTable() { | |
| var $table = $('table.datadisplaytable[summary="This layout table is used to present the sections found"]'); | |
| if ($table.length < 1) { | |
| return; | |
| } | |
| $table.removeClass("datadisplaytable"); | |
| $table.addClass("table table-hover table-striped"); | |
| $('div.pagebodydiv').removeClass('container'); | |
| var numcols = 0; | |
| $table.find("tbody > tr").each(function(i, tr) { | |
| if (i <= 1) { | |
| numcols = Math.max(numcols, $(tr).children().length); | |
| return; | |
| } | |
| if ($(tr).children().length < numcols) { | |
| $(tr).prepend('<td></td>'); | |
| } | |
| }); | |
| $table.find("tbody > tr").each(function(i, tr) { | |
| var children = $(tr).children(); | |
| $(children.get(5)).remove(); | |
| $(children.get(8)).remove(); | |
| }); | |
| } | |
| function augmentDropAddTable() { | |
| var $table = $('table.datadisplaytable[summary="Current Schedule"]'); | |
| if ($table.length < 1) { | |
| return; | |
| } | |
| $table.find('td.dddefault,th.ddheader').removeClass('dddefault ddheader'); | |
| $table.removeClass("datadisplaytable"); | |
| $table.addClass("table table-hover table-striped"); | |
| } | |
| function augmentGradesTable() { | |
| var $table = $('table.datadisplaytable[summary="This table displays the final\n' + | |
| 'grade for a class as well as the associated term, course, section, campus,\n' + | |
| 'credits, course title, attempted hours, earned hours, grade point average,\n' + | |
| 'and quality points for a level."]'); | |
| if ($table.length < 1) { | |
| return; | |
| } | |
| $table.find('td.dddefault,th.ddheader,th.ddlabel').removeClass('dddefault ddheader ddlabel'); | |
| $table.removeClass("datadisplaytable"); | |
| $table.addClass("table table-hover table-striped"); | |
| } | |
| function augmentAndResizeTable(table_selector, size) { | |
| var $table = $(table_selector); | |
| if ($table.length < 1) { | |
| return; | |
| } | |
| $table.find('td.dddefault,th.ddheader,th.ddlabel').removeClass('dddefault ddheader ddlabel'); | |
| $table.removeClass("datadisplaytable"); | |
| $table.addClass("table table-hover table-striped"); | |
| var $row = $('<div class="clearfix">'); | |
| var $div = $('<div class="col-' + size + '"></div>'); | |
| $row.insertAfter($table); | |
| $div.append($table); | |
| $row.append($div); | |
| } | |
| function augmentGradesAverageTable() { | |
| return augmentAndResizeTable('table.datadisplaytable[summary="This layout table displays the users current, cumulative,\n' + | |
| 'transfer and overall Grade point average information."]', 'md-6'); | |
| } | |
| function augmentStudentInformationTable() { | |
| return augmentAndResizeTable('table.datadisplaytable[summary="This layout table contains the users curriculum information for the specified term."]', 'md-6'); | |
| } | |
| function augmentAccountSummaryTable() { | |
| return augmentAndResizeTable('table.datadisplaytable[summary="This table displays summarized charge and payment transactions on your academic record."]', 'md-12'); | |
| } | |
| function augmentAccountSummaryByTermTable() { | |
| return augmentAndResizeTable('table.datadisplaytable[summary="This table displays summarized charge and payment transactions by term on your academic record."]', 'md-12'); | |
| } | |
| function augmentWeeklyScheduleTable() { | |
| $('table.datadisplaytable[summary="This layout table is used to present the weekly course schedule."]').data('batata-disabled', true); | |
| } | |
| function augmentCourseSearchTable() { | |
| var $table = $('table.datadisplaytable[summary="This layout table is used to present the course found"]'); | |
| $table.find('td[width]').removeAttr('width'); | |
| var lasttds = $table.find('tr > td:last-child'); | |
| lasttds.attr('width', '15%'); | |
| lasttds.find('br').remove(); | |
| lasttds.find('input[type=submit]').addClass("btn btn-default btn-sm"); | |
| return augmentAndResizeTable($table, 'md-8 col-md-offset-2'); | |
| } | |
| function augmentRegistrationOverridesTable() { | |
| return augmentAndResizeTable('table.datadisplaytable[summary="This table contains information about\n'+ | |
| 'Registration Permits and Overrides."]', 'md-6'); | |
| } | |
| function augmentRegistrationCreditsTable() { | |
| return augmentAndResizeTable('table.datadisplaytable[summary="This table contains information about\n'+ | |
| 'Level and Credit earned to date."]', 'md-6'); | |
| } | |
| function augmentRegistrationTables(size) { | |
| $('table.datadisplaytable').each(function() { | |
| var theSize = $(this).data('batata-size') || size; | |
| var theEnabled = !$(this).data('batata-disabled'); | |
| if (theEnabled) { | |
| augmentAndResizeTable($(this), theSize); | |
| } | |
| }); | |
| } | |
| function augmentBorderTablesWhateverThatMeans(size) { | |
| $('table.bordertable').each(function() { | |
| augmentAndResizeTable($(this), size); | |
| }); | |
| } | |
| var logMeOutTimeout; | |
| function doNotLogMeOutAfterTenMinutes() { | |
| var url = "https://www-banner.aub.edu.lb/pls/weba/twbkwbis.P_GenMenu?name=bmenu.P_GenMnu"; | |
| $.get(url).done(function (data) { | |
| if (data.lastIndexOf('<TITLE>Personal Information Menu</TITLE>') < 0) { | |
| console.log("You were logged out!"); | |
| alert("You were logged out!"); | |
| return; | |
| } | |
| keepMeLoggedIn(); | |
| }).fail(function () { | |
| keepMeLoggedIn(); | |
| }); | |
| } | |
| var betweenMin = 4; | |
| var betweenMax = 9; | |
| function lessThanTenMinutes() { | |
| return 1000 * 60 * Math.floor(betweenMin + Math.random() * (betweenMax - betweenMin)); | |
| } | |
| function keepMeLoggedIn(timeout) { | |
| if (timeout == undefined) { | |
| timeout = lessThanTenMinutes(); | |
| } | |
| console.log("Now:", (new Date()).toString(), "/ In", timeout/60000, "minutes, get the page."); | |
| logMeOutTimeout = setTimeout(doNotLogMeOutAfterTenMinutes, timeout); | |
| } | |
| function colorizeMenuLinks() { | |
| //~ $(".menu-item a.btn"). | |
| } | |
| function infoTextDivs() { | |
| $("div.infotextdiv").each(function(i, el) { | |
| var $box = $(el); | |
| $box.addClass("center-block bg-info"); | |
| }); | |
| $('div.pagebodydiv').find('table.plaintable[summary="This layout table holds message information"],div.infotextdiv').each(function() { | |
| var $img = $(this).find('img.headerImg'); | |
| var alertType = "success"; | |
| if ($img.attr("alt") == "Stop") { | |
| alertType = "danger"; | |
| } else if ($img.attr("alt") == "Help") { | |
| alertType = "warning"; | |
| } else if ($img.attr("alt") == "Information") { | |
| alertType = "info"; | |
| } | |
| console.log(alertType, this); | |
| var $alert = $('<div class="alert" role="alert">'); | |
| $alert.addClass('alert-' + alertType); | |
| $alert.text($(this).text()); | |
| $(this).replaceWith($alert); | |
| }); | |
| } | |
| if (document.location.href === "https://www-banner.aub.edu.lb/pls/weba/bwxaddi.p_viewaccttotal") { | |
| stylize(); | |
| keepMeLoggedIn(); | |
| $("html > body > center > p.whitespace1").addClass("col-md-6 col-md-offset-3"); | |
| var $t1 = $("html > body > center > p.whitespace1 > table.datadisplaytable:first-child"); | |
| $t1.addClass("table table-condensed"); | |
| var $t2 = $("html > body > center > p.whitespace1 > table.datadisplaytable:last-child"); | |
| $t2.addClass("table text-center"); | |
| $t2.find("tr:nth-child(6)").addClass("active"); | |
| $t2.find("tr:nth-child(7)").addClass("warning"); | |
| $t2.find("tr:nth-child(8)").addClass("active"); | |
| $t2.find("tr:nth-child(9)").addClass("danger"); | |
| $t2.find("tr:last-child").addClass("info"); | |
| window.onload = function() { | |
| var a = killCSSRule('TABLE TD.dddefault', 'print'); | |
| var b = killCSSRule('TABLE TH.dddefault', 'print'); | |
| var c = killCSSRule('Table TH.ddlabel', 'print'); | |
| var d = killCSSRule('Table.datadisplaytable', 'print'); | |
| console.log(a, b, c); | |
| }; | |
| } else { | |
| stylize(); | |
| header(); | |
| body(); | |
| footer(); | |
| loginForm(); | |
| selectTermForm(); | |
| otherSelectTermForm(); | |
| removeOnSubmit(); | |
| mainMenu(); | |
| augmentNavMenu(); | |
| augmentCourseTable(); | |
| augmentDropAddTable(); | |
| augmentGradesTable(); | |
| //~ augmentGradesAverageTable(); | |
| //~ augmentStudentInformationTable(); | |
| augmentAccountSummaryTable(); | |
| augmentAccountSummaryByTermTable(); | |
| //~ augmentRegistrationOverridesTable(); | |
| //~ augmentRegistrationCreditsTable(); | |
| augmentCourseSearchTable(); | |
| augmentWeeklyScheduleTable(); | |
| //~ if (document.location.href == 'https://www-banner.aub.edu.lb/pls/weba/bwskrsta.P_RegsStatusDisp') { | |
| augmentRegistrationTables('md-6'); | |
| augmentBorderTablesWhateverThatMeans('md-12'); | |
| //~ } | |
| infoTextDivs(); | |
| var a = $('input[type=submit],input[type=reset],input[type=button],button').filter(':not(.btn)').addClass('btn btn-default btn-sm'); | |
| console.log('Buttons', a); | |
| keepMeLoggedIn(); | |
| $(document).ready(function() { | |
| killCSSRule('A:link'); | |
| killCSSRule('A:visited'); | |
| killCSSRule('A:active'); | |
| killCSSRule('A:hover'); | |
| }); | |
| } | |
| } | |
| inject("injmain", injmain); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment