-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.js
143 lines (136 loc) · 3.94 KB
/
options.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
var trumps = [
'Lord Voldemort',
'Golden Wrecking Ball',
'The Most Fabulous Whiner',
'Fuckface von Clownstick',
'Man-Baby',
'Unrepentant Narcissistic Asshole',
'Short-Fingered Vulgarian',
'Tiny Hands Dildo',
'Babyfingers Dildo',
'Pixie Fingers Dildo',
'Agent Orange',
'The Dildo of Doom',
'Angry Creamsicle',
'Human-toupee Hybrid',
'Orange Manatee',
'Decomposing Jack-o-lantern',
'Fascist Carnival Barker',
'A Racist Clementine',
'Sentient Caps-lock Button',
'70-year-old Toddler',
'Cheeto Jesus',
'Failed Mail-order Meat Salesman',
'The Angry Cheeto',
'Douchebag',
'Not My President',
'The Turd Monster',
'America’s Back Mole',
'Rome Burning in Man Form',
'Donald Drumpf',
'Orange Slug',
'Crybaby Trump',
'Diaper Donald',
'Moneydiaper McStupid',
'The Incredible Douche',
'Dodgy Donald',
'Seagull Dipped In Tikka Masala',
'Bursting Landfill',
'Municipal Solid Waste',
'Rotting Whale Blubber',
'Sputum-filled Orange Julius',
'Gangrenous Gaping Wound',
'Racist, Sexist Block of Aged Cheddar',
'Oversized Wasp Exoskeleton',
'Old Mustard Face',
'Neo-fascist Real Estate Golem',
'Abandoned Roadside Ham Hock',
'Rotting Spam',
'Reanimated Roadkill',
'Heaving Carcass',
'Stately Hot Dog Casing',
'Flatulent Leather Couch',
'Swollen Earthworm Gizzard',
'Rotten Gazpacho',
'A Pair Of Chapped Lips Superglued To A Hairball',
'Malignant Corn Chip',
'Roiling Cheez Whiz Mass',
'Screaming Giant Cheese Wedge',
'Temperamental Gelatinous Sponge',
'Sentient Hate-balloon',
'Sun-kissed Ass Plug',
'Self-tanning Enthusiast',
'An Enraged, Bewigged Fetus',
'Human-shaped Wad Of gak',
'Walking Irradiated Tumor',
'Uncooked Chicken Breast',
'Seeping Fleabag',
'Irradiated Bat Urine',
'Sentient Waste Disposal Plant',
'A Disappointment',
'Poorly-drawn Fascist',
'Racist Teratoma',
'Lamprey Eel Spray-painted Gold',
'Sunken, Corroding Soufflé',
'Nacho Cheese Golem',
'Undead Tangerine',
'Fossilized Meatball',
'Radioactive Spray-tan',
'Tattered Craigslist Sofa',
'Play-Doh Factory Explosion',
'A New Superfood Made Of Finely-ground Clown Wigs',
'Unkempt Troll Doll',
'Rancid Beluga Caviar',
];
// Saves options to chrome.storage.sync.
function save_options() {
var word = document.getElementById('replace_word').value;
var replace = document.getElementById('replace').checked;
var redirect = document.getElementById('redirect').checked;
chrome.storage.sync.set({
replaceDT: replace,
redirectDT: redirect,
wordDT: word
}, function() {
// Update status to let user know options were saved.
var status = document.getElementById('status');
status.textContent = 'Options saved.';
setTimeout(function() {
status.textContent = '';
}, 750);
});
}
// Restores select box and checkbox state using the preferences
// stored in chrome.storage.
function restore_options() {
// Use default value color = 'red' and replaceDT = true.
chrome.storage.sync.get({
wordDT: 'Not My President',
replaceDT: true,
redirectDT: true
}, function(items) {
document.getElementById('replace_word').value = items.wordDT;
document.getElementById('replace').checked = items.replaceDT;
document.getElementById('redirect').checked = items.redirectDT;
});
}
function random_no_repeats(array) {
var copy = array.slice(0);
return function() {
if (copy.length < 1) { copy = array.slice(0); }
var index = Math.floor(Math.random() * copy.length);
var item = copy[index];
copy.splice(index, 1);
return item;
};
}
// Randomly generate Trump Nickname
var randomWord = random_no_repeats(trumps);
function generate_word() {
document.getElementById('replace_word').value = randomWord();
}
document.addEventListener('DOMContentLoaded', restore_options);
document.getElementById('generate_word')
.addEventListener('click', generate_word);
document.getElementById('save')
.addEventListener('click', save_options);