-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdiscord-authorization-helper.user.js
63 lines (54 loc) · 1.85 KB
/
discord-authorization-helper.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// ==UserScript==
// @name Discord Authorization Page Helper
// @namespace https://github.com/DevYukine
// @version 0.2
// @description Makes the authorization page nicer c:
// @author DevYukine
// @match *://discord.com/oauth2/authorize*
// @license MIT
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_addStyle
// @grant GM_registerMenuCommand
// @require https://raw.github.com/odyniec/MonkeyConfig/master/monkeyconfig.js
// @updateURL https://raw.githubusercontent.com/DevYukine/discord-authorization-helper/main/discord-authorization-helper.user.js
// @downloadURL https://raw.githubusercontent.com/DevYukine/discord-authorization-helper/main/discord-authorization-helper.user.js
// ==/UserScript==
(function () {
'use strict';
const config = new MonkeyConfig({
title: 'Discord Authorization Page',
menuCommand: true,
params: {
removeGuildsJoinScope: {
type: 'checkbox',
default: true
},
removeEmailScope: {
type: 'checkbox',
default: false
},
skipPromptIfPossible: {
type: 'checkbox',
default: false
}
}
});
const urlParams = new URLSearchParams(location.search);
if (RegExp('discord.com/oauth2/authorize').test(document.referrer)) {
console.log('previos page was authorize, exiting');
return;
}
let href = location.href;
const scopes = urlParams.get("scope").split(' ');
if (config.get('removeGuildsJoinScope') && scopes.includes('guilds.join')) {
console.log('found guilds.join scope, removing it');
href = href.replace(/guilds.join/, '');
}
if (config.get('removeEmailScope') && scopes.includes('email')) {
console.log('found email scope, removing it');
href = href.replace(/email/, '');
}
console.log('moving to new domain');
location.assign(`${href}${config.get('skipPromptIfPossible') ? '&prompt=none' : ''}`);
})();