Skip to content

Commit

Permalink
Huge Improvements + Features + V2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
DeadPackets committed May 5, 2018
1 parent b4a3863 commit 95df1de
Show file tree
Hide file tree
Showing 7 changed files with 198 additions and 25 deletions.
1 change: 1 addition & 0 deletions assets/emoji.css

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,32 @@ chrome.storage.onChanged.addListener((changes) => {
options[key] = changes[key].newValue;
})
})

let crnInfo = chrome.contextMenus.create({
title: "Get Information About This CRN",
contexts: ["selection"]
});

let termCodes = [{
name: "Fall 2018",
code: 201910
},
{
name: "Summer 2018",
code: 201830
},
{
name: "Summer II 2018",
code: 201840
}]

termCodes.forEach((item) => {
chrome.contextMenus.create({
title: item.name,
contexts: ["selection"],
parentId: crnInfo,
onclick: (info, tab) => {
chrome.tabs.create({url: `https://banner.aus.edu/axp3b21h/owa/bwckschd.p_disp_detail_sched?term_in=${item.code}&crn_in=${info.selectionText}`})
}
})
})
90 changes: 90 additions & 0 deletions content.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,13 @@ const tweaks = {
frame.addEventListener("load", function () {
let text = $(this.contentWindow.document).find('.warningtext').text()
if (text.indexOf('No holds exist') > -1) {
console.log("No holds found!")
return true;
} else {
if ($(this.contentWindow.document)[0].body.innerHTML.indexOf('User Login') > -1) {
console.warn('You are not logged in for View Holds to work!');
} else {
console.log(text);
new Noty({
type: 'warning',
text: 'You have some registration holds! Click here to see them.',
Expand Down Expand Up @@ -236,6 +238,93 @@ const tweaks = {
$('.infotext').parent().parent().remove();
}
}
},
mainMeowMenu: () => {
if (document.getElementsByName('mainFrame')[0] !== undefined) {
let frame = $(document.getElementsByName('mainFrame')[0].contentWindow.document);
$(frame).find('img[alt="aus"]').each((i, item) => {
$(item).attr('src', 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==');
$(item).attr('src', 'https://cataas.com/cat/cute?he=80&wi=80&id=' + Math.random())
})
} else {
$('img[alt="aus"]').each((i, item) => {
$(item).attr('src', 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==');
$(item).attr('src', 'https://cataas.com/cat/cute?he=80&wi=80&id=' + Math.random())
})
}
},
emojiGrades: () => {
if (document.getElementsByName('mainFrame')[0] !== undefined) {
let frame = $(document.getElementsByName('mainFrame')[0].contentWindow.document);
} else {
if (document.location.href.indexOf('P_ViewGrde') > -1)
{
$('tbody td:nth-child(7)').each((i, item) => {
let grade = $(item).text()
let emoji = '';
switch(grade)
{
case 'A':
emoji = 'fire';
break;
case 'A-':
emoji = '--1';
break;
case 'B+':
emoji = 'blush';
break;
case 'B':
emoji = 'smiley';
break;
case 'B-':
emoji = 'dissapointed';
break;
case 'C+':
emoji = 'slightly_smiling_face';
break;
case 'C':
emoji = 'upside_down_face';
break;
case 'C-':
emoji = 'joy';
break;
case 'D':
emoji = 'skull';
break;
case 'F':
emoji = '100';
break;
}

$(item).append(`<i style="float: right;" class="em em-${emoji}"></i>`)
})

$('tr td:nth-child(6) .rightaligntext').each((i, item) => {
let gpa = parseFloat($(item).text());
console.log(gpa);

if (gpa == 4.0) {
emoji = 'fire';
} else if (gpa >= 3.5 && gpa <= 3.99) {
emoji = 'sunglasses'
} else if (gpa >= 3.0 && gpa <= 3.49) {
emoji = 'smile'
} else if (gpa >= 2.5 && gpa <= 2.99) {
emoji = 'expressionless'
} else if (gpa >= 2.0 && gpa <= 2.49) {
emoji = 'upside_down_face'
} else if (gpa >= 1.5 && gpa <= 1.99) {
emoji = 'joy'
} else if (gpa >= 1.0) {
emoji = 'skull'
} else {
emoji = '100'
}

$(item).append(`<i style="float: right;" class="em em-${emoji}"></i>`)
})
}
}
}
}

Expand All @@ -249,4 +338,5 @@ $(() => {
}
})
})

})
5 changes: 3 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "BannerPlus",
"description": "Makes banner better.",
"version": "1.7",
"version": "2.0",
"icons": {
"128": "assets/icons/128.png"
},
Expand All @@ -18,13 +18,14 @@
{
"matches": ["*://banner.aus.edu/*"],
"js": ["/assets/jquery.slim.min.js", "content.js", "/assets/noty.min.js"],
"css": ["/assets/noty.min.css"]
"css": ["/assets/noty.min.css", "/assets/emoji.css"]
}
],
"permissions": [
"activeTab",
"tabs",
"storage",
"contextMenus",
"webRequest",
"webRequestBlocking",
"*://banner.aus.edu/*"
Expand Down
17 changes: 12 additions & 5 deletions popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,6 @@
padding-bottom: 10px;
}

.socialBadge {
padding-top: 10px;
padding-bottom: 10px;
color: #6b6b6b;
}
</style>

<!-- Assets -->
Expand Down Expand Up @@ -287,6 +282,14 @@ <h3>Misc Tweaks</h3>
<span class="optionText">Hide Banner Warning</span>
<input type="checkbox" name="hideBannerWarning" class="checkbox-switch" />
</div>
<div class="optionDiv">
<span class="optionText">Main Meow Menu</span>
<input type="checkbox" name="mainMeowMenu" class="checkbox-switch" />
</div>
<div class="optionDiv">
<span class="optionText">Emoji Grades</span>
<input type="checkbox" name="emojiGrades" class="checkbox-switch" />
</div>
<hr />
<h3>Auto Login</h3>
<div class="optionDiv">
Expand All @@ -307,6 +310,10 @@ <h3>Settings</h3>
<span class="optionText">Disable Auto Refresh</span>
<input type="checkbox" name="disableAutoRefresh" class="checkbox-switch" />
</div>
<div class="optionDiv">
<span class="optionText">Dark Theme</span>
<input type="checkbox" name="darkTheme" class="checkbox-switch" />
</div>
<br />
</div>

Expand Down
75 changes: 60 additions & 15 deletions popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ function clickSwitch(name, currentValue, tab) {

return;
})
} else if (name == 'darkTheme') {
chrome.storage.sync.set({
darkTheme: currentValue
}, () => {
window.close();
});
}

let data = {};
Expand All @@ -74,24 +80,51 @@ function initializeSwitches(tab) {
$('[name="password"]').val(result.password);
})
}

chrome.storage.local.get([name], (result) => {
if (result[name]) {
new Switch(item, {
size: 'default',
checked: true,
onChange: (value) => {
clickSwitch(name, value, tab);
chrome.storage.sync.get(['darkTheme'], (result) => {
if (result.darkTheme) {
chrome.storage.local.get([name], (result) => {
if (result[name]) {
new Switch(item, {
size: 'default',
onSwitchColor: '#2d89ef',
offSwitchColor: '#202020',
checked: true,
onChange: (value) => {
clickSwitch(name, value, tab);
}
});
} else {
new Switch(item, {
size: 'default',
onSwitchColor: '#2d89ef',
offSwitchColor: '#202020',
checked: false,
onChange: (value) => {
clickSwitch(name, value, tab);
}
});
}
});
})
} else {
new Switch(item, {
size: 'default',
checked: false,
onChange: (value) => {
clickSwitch(name, value, tab);
chrome.storage.local.get([name], (result) => {
if (result[name]) {
new Switch(item, {
size: 'default',
checked: true,
onChange: (value) => {
clickSwitch(name, value, tab);
}
});
} else {
new Switch(item, {
size: 'default',
checked: false,
onChange: (value) => {
clickSwitch(name, value, tab);
}
});
}
});
})
}
})
});
Expand Down Expand Up @@ -155,9 +188,21 @@ function displayDisclaimer(cb) {
})
}

function darkTheme() {
chrome.storage.sync.get(['darkTheme'], (result) => {
if (result.darkTheme) {
$('body').css('background-color', '#363636');
$('span').css('color', '#c5c5c5');
$('h3').css('color', 'white');
$('hr').css('border-color', '#8f8f8f');
}
})
}

document.addEventListener('DOMContentLoaded', () => {
getCurrentTabUrl((tab) => {
if (tab.url.indexOf('banner.aus.edu') > -1) {
darkTheme();
initializeSwitches(tab);
checkForUpdates();
displayDisclaimer(() => {
Expand Down
6 changes: 3 additions & 3 deletions version.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"version": "1.32",
"changelog": ["Added Dark Theme", "Added GrayScale Theme", "Added Highlighting Closed or Open Courses", "Added Bigger Checkboxes", "Seperated tweaks into categories", "Added the hiding of Banner's indimidating warning message", "Fixed auto login not turning off after being enabled"]
}
"version": "2.0",
"changelog": ["Added Dark Theme", "Added GrayScale Theme", "Added Highlighting Closed or Open Courses", "Added Bigger Checkboxes", "Seperated tweaks into categories", "Added the hiding of Banner's indimidating warning message", "Fixed auto login not turning off after being enabled", "Added BannerPlus Dark Theme", "Added Cats to Banner", "Now you can see your grades in emojis!"]
}

0 comments on commit 95df1de

Please sign in to comment.