NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript==
// @name Pooya Courses Filter
// @match https://pooya.um.ac.ir/educ/prof_portal/PresentedCoursesForm.php*
// @version 1
// @grant none
// @run-at document-end
// @require https://code.jquery.com/jquery-3.3.1.js
// @license MIT
// ==/UserScript==
gender = false; //"مرد"
faculty = false; //"مهندسی"
group = false; //"کامپیوتر"
addSpace = false; //true
time = "چهارشنبه ساعت 12";//false;//"سه شنبه ساعت 10";
locat = false;//"B-37";
var urlParam = function (name, url) {
if (!url) {
url = window.location.href;
}
var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(url);
if (!results) {
return undefined;
}
return decodeURIComponent(results[1]) || undefined;
};
var replaceAll = function (str, mapObj) {
var re = new RegExp(Object.keys(mapObj).join('|'), 'gi');
return str.replace(re, function (matched) {
return mapObj[matched.toLowerCase()];
});
};
var faOrAr = function (string, mode) {
var findReplacements = (mode == 'fa') ? {
'ي': 'ی',
'ك': 'ک'
}
: {
'ک': 'ك',
'ی': 'ي'
};
return replaceAll(string, findReplacements);
};
var searchFa = function (find, str) {
if (addSpace) {
find = ' ' + find + ' ';
}
return str.search(faOrAr(find, 'fa')) != - 1 || str.search(faOrAr(find, 'ar')) != - 1;
};
var hasMouseMove = 0;
try {
document.removeEventListener('mousemove', moveMouse, false);
hasMouseMove = 1;
} catch (e) {
}
var jQueryReady = function () {
correctFormAction();
var img,
text;
$('table').find('td:last-child > img').each(function() {
img = $(this);
text = img.attr('title');
if ((time && !searchFa('> ' + time, text)) || (locat && text.search(locat) == -1)) {
img.parents('tr').hide();
}
if (gender && !searchFa(gender, text)) {
img.parents('tr').css('background', '#333');
} else if ((faculty && !searchFa(faculty, text)) || (group && !searchFa(group, text))) {
img.parents('tr').css('background', '#444');
}
img.replaceWith('<div>' + text + '</div>');
//img.hide();
//img.parent().append('<div>' + text + '</div>');
});
if (hasMouseMove) {
document.addEventListener('mousemove', moveMouse, false);
}
};
var correctFormAction = function () {
$('form').attr('action', window.location.href);
};
jQueryReady();