Skip to content

Instantly share code, notes, and snippets.

View codeyourwayup's full-sized avatar

FRANK GO codeyourwayup

View GitHub Profile
<button id="elem" onclick="alert('Click!');">Autoclick</button>
<script>
let event = new Event("click");
elem.dispatchEvent(event);
</script>
<h1 id="elem">Hello from the script!</h1>
<script>
import RestocksService from '../../../services/supreme/RestocksService';
import StorageService from '../../../services/StorageService';
import ChromeService from '../../../services/ChromeService';
export default class RestockMonitor {
constructor(intervalMs) {
this.intervalMs = intervalMs;
this.onNewProductsCallbacks = [];
this.onProductsRestockCallbacks = [];
}
function setWithExpiry(key, value, ttl) {
const now = new Date()
// `item` is an object which contains the original value
// as well as the time when it's supposed to expire
const item = {
value: value,
expiry: now.getTime() + ttl,
}
localStorage.setItem(key, JSON.stringify(item))
function getWithExpiry(key) {
const itemStr = localStorage.getItem(key)
// if the item doesn't exist, return null
if (!itemStr) {
return null
}
const item = JSON.parse(itemStr)
const now = new Date()
// compare the expiry time of the item with the current time
if (now.getTime() > item.expiry) {
This means that 1rem equals the font size
of the html element (which for most browsers has a default value of 16px).
(function () {
var ROOT_URL = "https://canopy.co";
var PRICE_SELECTORS = [
".priceLarge",
".a-color-price.a-size-large",
".a-color-price.a-size-medium",
"#priceblock_ourprice"
];
var IMAGE_SELECTORS = [
@codeyourwayup
codeyourwayup / mask-array.js
Created June 30, 2021 09:58
Mask an array to calculate sub-array average
function ave(arr) {
if (arr && arr.length) {
//easy way to get array total is using reduce; c is current
const total = arr.reduce((a, c) => {
return a + c;
});
return total / arr.length;
}
throw new Error('wrong arr');
};
@codeyourwayup
codeyourwayup / git-rebase-todo
Created June 18, 2022 06:52 — forked from juniorbird/git-rebase-todo
Sample git rebase todo
pick 019325e 0.1.0
pick a4b689d Fetch all dependencies
squash 714a49d Matches keywords to Docker repos
pick d2d1ca3 parseDependencies returns an object of dependencies.
squash e3b6cd9 Clean up packageParser
squash 57acd67 Initial commit
squash 3f3e05e Rough out how we'll make Dockerfiles
squash 9e10b94 Can check for, make Docker files
squash a27b0ee Write docker files
pick a0980b8 Build Dockerfiles
@codeyourwayup
codeyourwayup / simulate_keypress.js
Created February 8, 2023 01:49 — forked from ejoubaud/simulate_keypress.js
Simulate keypress that works in Google nav in Chrome
// Based on http://stackoverflow.com/a/10520017/1307721 and http://stackoverflow.com/a/16022728/1307721
Podium = {};
Podium.keydown = function(k) {
var oEvent = document.createEvent('KeyboardEvent');
// Chromium Hack
Object.defineProperty(oEvent, 'keyCode', {
get : function() {
@codeyourwayup
codeyourwayup / recorder.html
Created March 4, 2023 10:14 — forked from liketaurus/recorder.html
How to record audio in client code and upload recording to AWS S3 bucket
<!-- https://medium.com/@bryanjenningz/how-to-record-and-play-audio-in-javascript-faa1b2b3e49b -->
<!-- https://docs.aws.amazon.com/en_us/sdk-for-javascript/v2/developer-guide/s3-example-photo-album.html -->
<script src="https://sdk.amazonaws.com/js/aws-sdk-2.585.0.min.js"></script>
<script>
function uploadAWS(blob) {
var vaultBucketName = "[YOUR-BUCKET-NAME]";
var bucketRegion = "[YOUR-AWS-REGION]";
var IdentityPoolId = "[YOUR-IDENTITY-POOL-ID]";