Skip to content

Commit

Permalink
Created options for notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
Azkellas committed Oct 12, 2018
1 parent 32a9358 commit da95c96
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ It might work on chromium-based browser, such as opera and safari, but was not t

It is only my second time using javascript (and first with jquery/angular) so the code is without doubt full of atrocities, bad habits and more. Feel free to report them or to improve the code if you're brave enough to have a look at it. :)

Angular debug mode is used for the agent panel (quick selection and such) and might use a lot of RAM. You can disable it by setting `const useAgentModule` to `false`.
Angular debug mode is used for the agent panel (quick selection and such) and might use a lot of RAM. You can disable it by setting `useAgentModule` to `false`.

## How to install

Expand All @@ -25,6 +25,7 @@ The script currently has no option panel. However since it's a userscript, any u
Options are to be found at the beginning of the script (line 25 or around). Look for `//options` in the source code. As of today, two options are available:
* **useAgentModule**: allow the agent options. This is the only part of the script that uses the angular debug mode. This mode might use a lot of RAM, so disable it to save some if CG is slower than usual.
* **forceExternRequest**: Make the leaderboard api request extern. It allows you to play against AIs of higher leagues in the agent panel but this might disrupt other features if you are not in the top1000.
* **notifToRemove**: Array storing the different notifications to remove. They are about 30 different types of notifications on CG, a list is available above this option.

## Features

Expand Down
33 changes: 18 additions & 15 deletions script.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,20 @@
var useAgentModule = true; // set to false to disable angular debug mode (and agent panel)
var forceExternRequest = false; // set to true to enable fighting against bots of higher leagues

// existing notifications
// 'clash-invite', 'clash-over', 'invitation-accepted'
// 'contest-scheduled', 'contest-started', 'contest-over', 'contest-soon'
// 'new-league', 'new-league-opened', 'new-blog', 'new-comment', 'new-comment-response', 'new-puzzle', 'new-hint', 'new-level'
// 'contribution-received', 'contribution-accepted', 'contribution-refused'
// 'following', 'friend-registered'
// 'achievement-unlocked'
// 'promoted-league', 'eligible-for-next-league'
// 'puzzle-of-the-week'
// 'career-new-candidate', 'career-update-candidate'
// 'feature', 'custom'
const enableSound = false;
const notifToRemove = ['clash-invite', 'following'];

var GMsetValue;
var GMgetValue;
var GMxmlhttpRequest;
Expand Down Expand Up @@ -455,21 +469,10 @@
var config = { attributes: true, childList: true, characterData: true, subtree: true};

// disallow sound for notifications
if (unsafeWindow.session.notificationConfig.soundEnabled)
unsafeWindow.session.notificationConfig.soundEnabled = false;

// notifications
// 'clash-invite', 'clash-over', 'invitation-accepted'
// 'contest-scheduled', 'contest-started', 'contest-over', 'contest-soon'
// 'new-league', 'new-league-opened', 'new-blog', 'new-comment', 'new-comment-response', 'new-puzzle', 'new-hint', 'new-level'
// 'contribution-received', 'contribution-accepted', 'contribution-refused'
// 'following', 'friend-registered'
// 'achievement-unlocked'
// 'promoted-league', 'eligible-for-next-league'
// 'puzzle-of-the-week'
// 'career-new-candidate', 'career-update-candidate'
// 'feature', 'custom'
const notifToRemove = ['clash-invite', 'following'];
if (unsafeWindow.session.notificationConfig.soundEnabled !== enableSound)
unsafeWindow.session.notificationConfig.soundEnabled = enableSound;

// remove notifications
for (const notif of notifToRemove)
{
const idx = unsafeWindow.session.enabledNotifications.indexOf(notif);
Expand Down

0 comments on commit da95c96

Please sign in to comment.