Skip to content

Instantly share code, notes, and snippets.

View jdgregson's full-sized avatar

Jonathan Gregson jdgregson

View GitHub Profile
@jdgregson
jdgregson / Emoji Attack
Created April 23, 2018 18:45
Causes a web page to flip out and wild emojis to appear.
let r = Math.random;
let fl = Math.floor;
let b = document.getElementsByTagName('body')[0];
b.style.transition = 'all 1s ease-in-out';
b.style.overflow = 'hidden';
self.setInterval(() => {
let n = fl(r()*2);
let d = n?fl(r()*360):fl(r()*360)*-1;
let o1 = fl(r()*101)+1;
let o2 = fl(r()*101)+1;
@jdgregson
jdgregson / delete-tweets.js
Created November 30, 2018 23:29
Delete last year's tweets
let before = 2018;
let tweets = document.querySelectorAll('li.stream-item');
for(let i=0; i<tweets.length; i++) {
let tweet = tweets[i];
let date = tweet.querySelector('small.time').innerText;
let year = date.split(' ')[3];
if(year == parseInt(year) && year.length === 4 && parseInt(year) < before) {
let buttons = tweet.querySelectorAll('.dropdown-link');
for(let j=0; j<buttons.length; j++) {
if(buttons[j].innerText === 'Delete Tweet') {
@jdgregson
jdgregson / LockDownPnP.ps1
Last active January 11, 2022 02:38
Disable new PnP devices and lock the workstation
$Query = "SELECT * FROM __InstanceCreationEvent Within 1 WHERE TargetInstance ISA 'Win32_PnPEntity'"
Register-WmiEvent -Query $Query -Action {
$id = $EventArgs.NewEvent.TargetInstance["DeviceID"]
Write-Host "New PnP Device detected: $id"
$user = ((quser) -replace '^>', '') -replace '\s{2,}', ',' | ConvertFrom-Csv
Disable-PnPDevice -InstanceID $id -Confirm:$False
tsdiscon $user.ID
}
@jdgregson
jdgregson / get-twitter-image-urls.js
Created May 12, 2019 21:20
This script will scroll through a user's Twitter media page and copy the URL of each image. After completion, the URLs can be found in the `urls` variable.
let urls = [];
let timer = self.setInterval(() => {
window.scrollBy(0, parseInt(getComputedStyle(document.body).height));
let media = document.querySelectorAll('.AdaptiveMedia-photoContainer img');
for (let i = 0; i < media.length; i++) {
let src = media[i].getAttribute('src');
if (urls.indexOf(src) < 0) {
urls.push(src);
}
}
@jdgregson
jdgregson / simple-encoder.js
Created May 21, 2019 21:28
A simple text obfuscation technique.
function encode(string) {
return btoa(btoa((string.split('')).map((a) => {
return String.fromCharCode(a.charCodeAt()+-10)
}).join('')));
}
@jdgregson
jdgregson / chrome-secure-ciphers.bat
Created July 12, 2019 16:38
Disable insecure and less-than-256-bit ciphers in Chrome
chrome.exe --args --cipher-suite-blacklist=0x009c,0x009d,0x002f,0x0035,0x000a,0x0a0a,0x1a1a,0x2a2a,0x3a3a,0x4a4a,0x5a5a,0x6a6a,0x7a7a,0x8a8a,0x9a9a,0xaaaa,0xbaa,0xcaca,0xdada,0xeaea,0xfafa,0x0a,0x1a,0x2a,0x3a,0x4a,0x5a,0x6a,0x7a,0x8a,0x9a,0xaa,0xba,0xca,0xda,0xea,0xfa,0xc013,0xc014,0xc02b,0xc02f
@jdgregson
jdgregson / gist:7ddb21d5f55fa52d302d2cfb751ed520
Created July 15, 2019 23:09
CloudFlare API - Forwarding URL Page Rule (forwarding_url)
{
"targets": [
{
"target": "url",
"constraint": {
"operator": "matches",
"value": "*yourdomain.com/*"
}
}
],
@jdgregson
jdgregson / SecurePlainText.ps1
Created July 16, 2019 18:06
Utilities for working with text as secure strings.
function ConvertTo-SecurePlainText {
[cmdletbinding()]
Param (
[parameter(ValueFromPipeline)]
[string]$String = "",
[string]$File
)
Process {
if ($File) {
@jdgregson
jdgregson / Set-MaxMailSize.ps1
Created September 17, 2019 22:24
Sets the maximum message size to 150MB for new and existing Office 365 mailboxes.
$plans = Get-MailboxPlan | Where-Object {$_.MaxSendSize -ne "Unlimited"}
$plans | ForEach-Object {
Set-MailboxPlan $_.Name -MaxSendSize 150MB -MaxReceiveSize 150MB
}
Get-Mailbox -ResultSize Unlimited | Set-Mailbox -MaxReceiveSize 150MB -MaxSendSize 150MB
@jdgregson
jdgregson / Copy-Acl.ps1
Last active January 11, 2022 02:36
Copy an ACL from one file to another in PowerShell
Set-Acl -Path new.txt -AclObject (Get-Acl -Path old.txt)