Skip to content

Here you can fined many code snippets that I use in my projects and some cool developers. If you have some, Then you can collaborate with this repository.

Notifications You must be signed in to change notification settings

CodeWithMohaimin/Code-Snippets

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

Here are some of the most uses code snippet that developer use daily.

1. For adding an active class & Remove an active class

const btns = document.querySelectorAll(".ctrl-btn");
btns.forEach((btn) => {
  btn.addEventListener("click", () => {
    btns.forEach((tab) => {
      tab.classList.remove("active");
    });
    btn.classList.add("active");
  });
});

2. When Scroll down & When scroll up

function handleScroll(event) {
  if (event.deltaY > 0) {
    homeUpperContainer.classList.add("active");
  } else if (event.deltaY < 0) {
    homeUpperContainer.classList.remove("active");
  }
}

homeContainer.addEventListener("wheel", handleScroll);

3. Automatic Send Connect from console

document.querySelectorAll('[data-testid="connect-button"]').forEach((item) => {
  item.click();

document.querySelectorAll('[data-testid="connect-without-message-button"]').forEach((popupSendButton) => {
  popupSendButton.click();

  });
});


4. Automatic Send Friend Request

document.querySelectorAll('[aria-label="Add friend"]').forEach((item) => {
  item.click();
});

5. Change Existing Git Repo To New

git remote set-url origin https://github.com/CodeWithMohaimin/Wordpress.git

git remote remove origin
git remote add origin https://github.com/CodeWithMohaimin/Wordpress.git

git push -u origin master


6. Automatic Unfollow

document.querySelectorAll('[aria-label="Manage"]').forEach((item, i) => {
    setTimeout(() => {
        item.click();
        console.log(`Clicked Manage button for item ${i}`);

        setTimeout(() => {
            const unfriendButton = document.querySelector('img[src="https://static.xx.fbcdn.net/rsrc.php/v3/yw/r/Kluyv0pwyPt.png"]');
            if (unfriendButton) {
                unfriendButton.click();
                console.log(`Clicked Unfriend for item ${i}`);

                setTimeout(() => {
                    const confirmButton = document.querySelector('[aria-label="Confirm"]');
                    if (confirmButton) {
                        confirmButton.click();
                        console.log(`Confirmed Unfriend for item ${i}`);
                    } else {
                        console.log(`No confirm button found for item ${i}`);
                    }
                }, 1000);

            } else {
                console.log(`Unfriend button not found for item ${i}`);
            }
        }, 1000);

    }, i * 3000);
});


About

Here you can fined many code snippets that I use in my projects and some cool developers. If you have some, Then you can collaborate with this repository.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published