Skip to content

Instantly share code, notes, and snippets.

View M-Bekheet's full-sized avatar

Mahmoud Bekheet M-Bekheet

View GitHub Profile
@M-Bekheet
M-Bekheet / connector.js
Last active September 22, 2025 13:21
Auto connect sender on Linkedin
// utils
const nextBtnSelector = "button[aria-label='Next']";
const connectBtnsSelector = ".artdeco-button__text";
const sendBtnSelector =
".artdeco-modal__actionbar .artdeco-button.artdeco-button--2.artdeco-button--primary";
const timeBetweenEachClick = 2000;
const timeBeforeInteractingWithNextPage = 2000;
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
@M-Bekheet
M-Bekheet / this-in-javascript.md
Last active December 25, 2024 12:18
this in JavaScript

this keyword mainly refers to different values in JS. In most cases it refers to the scope it was called from, but I'll list how it holds values based on different conditions below.

A rule of thumb, look to the left of this. It's likely the value of it, unless for conditions mentioned below.

The coming examples expects that JS is called in the browser.

1. this in the global context

console.log(this) //window object
@M-Bekheet
M-Bekheet / Generics.ts
Last active January 12, 2023 20:00
TypeScript Generics
// Generics
/*
*
===> Ex1
*
*/
type G1<S> = {
data: S;
@M-Bekheet
M-Bekheet / innerHTML replacement for React
Created April 2, 2020 15:59
innerHTML doesn't invoke js scripts in html, but this range method does (use it with caution)
const html = `
your html here
`;
class App extends React.Component {
componentDidMount() {
const wrapper = document.querySelector('#d3_code');
const range = document.createRange();
range.setStart(wrapper, 0);
wrapper.appendChild(
@M-Bekheet
M-Bekheet / yt-playlist-duration-calc.js
Last active August 31, 2023 23:24
Youtube Playlist Duration Calculator
function getPlaylistDuration(selector) {
const wrappers = Array.from(document.querySelectorAll(selector || '.ytd-page-manager:not([hidden]) #thumbnail .ytd-thumbnail-overlay-time-status-renderer .ytd-thumbnail-overlay-time-status-renderer'))
const timeArr = [];
for (let i = 0; i < wrappers.length; i++) {
if (wrappers[i].innerText.trim().includes(':')) {
timeArr.push(wrappers[i].innerText.trim())
}
}
function getDuration(timeArr) {
let duration = 0