Skip to content

Instantly share code, notes, and snippets.

@karpatic
karpatic / Get Conversation
Created September 9, 2024 02:21
Facebook Conversation Scraper
let talker = 'left';
let messageData = [];
// Helper function to add a delay (1 second)
const delay = (ms) => new Promise(resolve => setTimeout(resolve, ms));
// Select the third grid element (index 2 since it's 0-based)
let grid = document.querySelectorAll('div[role="grid"]')[2];
// Function to check if a message already exists in the messageData array
async function getLatestGistUpdate(gistId, fileName) {
const url = `https://api.github.com/gists/${gistId}`;
try {
const response = await fetch(url);
if (!response.ok) {
throw new Error(`Failed to fetch gist: ${response.statusText}`);
}
const gistData = await response.json();
setInterval(() => {
document.querySelectorAll('*').forEach(element => {
if (element.textContent.trim() === 'Continue generating') {
element.click();
}
});
}, 1000);
<div style='display:flex; justify-content: flex-end;'>
<button style='background:red;color:white' name='remove'>Delete</button>
</div>
@karpatic
karpatic / bookmark.js
Last active April 16, 2024 20:55
Bookmark urls can be javascript:()(); This one imports and runs bookmark.js
console.log('success');
async function getCopiedText() {
try {
const text = await navigator.clipboard.readText();
console.log('Copied text:', text);
} catch (err) {
console.error('Failed to read clipboard contents:', err);
}
}
getCopiedText();
Get-ChildItem "C:\MyFolder" -File -Recurse | ForEach-Object { $_.CreationTime = Get-Date "03/15/2024 12:00:00" }
let control = [
"window",
"self",
"document",
"name",
"location",
"customElements",
"history",
"navigation",
"locationbar",
@karpatic
karpatic / a notes
Last active February 1, 2024 21:33
'lightmode darkmode toggle'
no cookies
no referrers
saturation color palette
90-50. ideally 80 characters long
px overides users zoom. use em.
~44px tap targets
sans-serif and monospace
people don't like animations
no requests after page load
@karpatic
karpatic / Openai chat
Last active January 19, 2024 01:21
OpenAI thread and chatbot integration example
// console.log(OpenAI.Audio.Speech); // Audio Speech // Assistant // Completions + Functions
// thread Id = thread_YkCHeyvt4cpTx3dsRCAXamji
// run Id = run_dXteBI7ldfWlJ27tlaQXygVQ
/*
const thread = await openai.beta.threads.create();
console.log('thread', thread.id);
// Add a Comment to a Thread
@karpatic
karpatic / Css @property test.html
Last active January 19, 2024 01:21
HTML and CSS code for a colorful spiral text animation. Not all browser support it yet
<!--
Original Post: https://twitter.com/compose/tweet
-->
<!DOCTYPE html>
<div id="spiral" class="spiral"></div>
<div id="spiral2" class="spiral"></div>
<script>
const ANIMATION_DURATION = 4000;