Whitening Google Sheet Prank

About this Tutorial

Drive your office crazy by setting a trigger to lighten the text and background of your sheet by 1 rgb point every time they edit, or based on every hour!

Learn how to create triggers in a fun way.

Video Transcript

0:00 So one of my past videos, I created a self-destructing Google Sheet where it runs a trigger that automatically destroys it, essentially puts it in the trash and then 30 days later, Google Drive is going to delete your Google Sheet.
0:13 Now that's sort of like, sort of a prank. And sort of like a fun idea to be like, oh, you can do that.
0:20 And it was like a fun way to show you Apps Script and a little bit of triggers. But today is actually a response to someone who was like, Hey, instead of destroying the entire sheet, what if you just make a- harder to like read?
0:34 What if you just like make everything turn white? And I was like, I wonder if you can do that slowly.
0:42 Like, could you drive someone insane if every hour of the day a trigger is triggered in Google Sheets and their text gets whiter and the background of their sheets gets whiter.
0:56 And so I did it. Here it is. Here's the whitening Google Sheet prank. You can get this code here in the sheet.
1:05 If you're a Better Sheets member down below if you're watching this somewhere on YouTube or something, then you should become a member and get this Apps Script.
1:13 But I'm gonna walk through this Apps Script a little bit, because I think it's really interesting. And I'm gonna show you triggers so that you can see how this would actually play out.
1:22 There are two functions here, one called white and text, and one called white and background. They both use a function of a hex to RGB and RGB to hex inside, because essentially every single color of text and background is both hex and RGB.
1:40 So if we want to change this color, we can definitely change the hex, but also we can change the RGB, and RGB is a mathematical equation because it's 0 to 255, right?
1:51 So if I put 0 here for all of these, it is black, if I do 255, of all three, it's white.
2:01 So this is the spectrum, we're going from 0 to 255, and we just need to like get to 255 from 0 or from 0.
2:09 Wherever it is, and so if we add, let's see if we add like 600 or 600, I think doing it this way, it like is taking away the numbers, but if I do it programmatically, it'll probably be like, hey, let's do 254.
2:25 Wait, sorry, 254, 254, and 254. And there's like, this is like the slightest possible gray possibly, right? And that's your text.
2:38 So that's how you can change colors. But let's look at. Doing it programmatically, what we have to do is we're grabbing the sheet that we're on.
2:49 We're going to grab the what, this is actually funny because it's not the entire sheet, it's just the cell that someone's in.
2:55 So if you are in this cell, then they're gonna just every, we can probably do it like every minute or every 10 minutes or every hour, whatever, they're, they're just things are gonna go a little bit whiter.
3:09 We're gonna look at that. So, we're actually just looking at the data range of this sheet that we're on the active spreadsheet.
3:20 We're gonna get the sheets, we're gonna go through all the value sorry, all of the data range. And for each cell, we are going to get the color.
3:31 So, this is text. Again, we're in white in text. We're gonna get the text color. We're then gonna change it from hex to RGB.
3:38 We're gonna take that RGB and do this math which is just add one. That's it. Then we're gonna take that added one and we're gonna change it back to hex color and then we're gonna set that font color here.
3:51 For the background, see this is called white in background, we're gonna do the same. We're gonna do the entire data range, get all the values, get all the ranges.
3:59 For each one of them, we're gonna get the background color, get background here. We're going to run it again, hex to RGB, add one to each RGB and then set it to the new color.
4:12 All right let me show you if we whiten text and if we click here and whiten. Background, let's click that and look at these colors.
4:23 They just, this is going to be a new color here. And I think the text is going to be the whitest white there.
4:30 It's already checked there. You can see. Let's whiten background. A couple more times, like two or three times. And then you're going to see three new colors.
4:40 I think we're going to see three new colors here. Yeah, we see these new colors are being added to custom.
4:46 So this custom is going to keep filling up with every single shape. Almost every single shade possible, or a third of them.
4:54 And if we just keep running this, white in background, we will see more and more of these shades. And someone's going to go slowly insane.
5:05 So, let's look at how, How do we trigger this, right? We're not going to come into someone's Google Sheet while they're working and then hit run every single time.
5:13 But triggers can do this for us. Over here on the left, we're going to hit triggers. We're going to then add a trigger.
5:22 We're going to choose, is whiten background. We're going to set a time trip. You can do based on some event.
5:28 Like if they do something in the sheet on like every edit. That would be crazy if every single, oh my god.
5:35 Let's look at this from spreadsheet on edit. So now every single time I edit the sheet, it's going to kick whiter and whiter.
5:42 So I'm, I find this insanely funny because of how many hours a day I spend on Google Sheets. And if someone did this to me, I would, I would go slow, I would slowly go insane.
5:54 Alright, let's see. The background is going to whiten every time we edit any cell. So if we, it's not whitening at all.
6:06 It's, oh my god, this is hilarious. This is a, makes me go insane if this is happening. Okay, I think I know what happened.
6:16 Because the white background is already white, it's actually flipping. So let me fix that. Okay, so this changing math.min to 255 should work.
6:24 It's just going to take the minimum value of these two options. And if RGB.red plus one is over 255, it'll take 255.
6:34 All right, let's see. This should, so it shouldn't flip from white to black anymore. If we run this again, actually, we can.
6:46 Change this. Let's change it to something like the background to here, text to here, to this, and now every time we edit, it's gonna go through, and I think, white and even more, everything.
7:08 Okay, we can actually see it working because it's adding these values here. It's so hard to see in the video.
7:16 I think. Oh, I can sort of start to see it now. Okay, this would absolutely drive me insane if somebody was doing this to me.
7:26 I can also add the trigger for the text, whiten text. From spreadsheet on edit and it's just going to get the data range that so it would have these lines in it.
7:40 Let's look again. This whiten background, whiten text. Okay, now it's going to do both. If I set any color here.
7:48 And I start typing. Hello. And I'm just filling in copy paste kind of stuff and I'm like, going not very fast but editing this data a little bit at a time.
8:04 Is it working? Yeah, so you can sort of see it working. It's magic a little bit at a time. It's adding these things every time I edit.
8:19 Change a cell. It's at, there it is. See, it's adding all these, oh my god. This is crazy. If you are a BetterSheets member, grab this sheet and this Apps Script yourself.
8:32 Grab it. You're more than welcome to check it out. I hope you learned something here a little bit. Crazy that you can set up a trigger of this thing when it's on edit.
8:40 We can also set this trigger to every minute, I think, so that somebody slowly goes insane. We can say time driven.
8:50 Let's say minutes. Every minute. Every minute. And it's just gonna from now on for a three hours go go from zero to not zero from whatever color it is to 255.
9:02 You can make it even very slowly. Let's go to time-driven. Daytime or so this will take about a year or just under two thirds of a year every day at 6 p.m.
9:17 It just whitens it a little bit more. Oh my god. That would be insane. So also if you want to delete these triggers just go over here to these three buttons.
9:25 And hit delete. I should probably tell you that now because you're gonna have to delete these triggers because someone's gonna go insane in your office if you use this.
9:33 Alright, enjoy. Bye.