Skip to content

Instantly share code, notes, and snippets.

View navchandar's full-sized avatar

NaveenChandar navchandar

View GitHub Profile
@navchandar
navchandar / IP copy bookmarklet.js
Created October 16, 2025 08:36
JS bookmarklet to copy IP to clipboard on click
// Bookmarklet to copy IP to clipboard with Multiple sources, Error handling and alerts
javascript:(function(){const ipServices=['https://api.ipify.org','https://icanhazip.com'];function fetchAndCopyIP(index=0){if(index>=ipServices.length){alert('Failed to retrieve IP from all sources.');return}
const url=ipServices[index];fetch(url).then(response=>{if(!response.ok){throw new Error(`Service ${url} failed with status: ${response.status}`)}
return response.text()}).then(ip=>{const trimmedIP=ip.trim();navigator.clipboard.writeText(trimmedIP).then(()=>{alert('IPv4 copied to clipboard: '+trimmedIP)}).catch(()=>{alert('Failed to copy IPv4 to clipboard. The IP is: '+trimmedIP)})}).catch(error=>{console.error(`Error fetching from ${url}:`,error);fetchAndCopyIP(index+1)})}
fetchAndCopyIP()})()
// Bookmarklet without alerts, silently copy IP to clipboard
javascript:(function(){const ipServices=['https://api.ipify.org','https://icanhazip.com'];function fetchAndCopyIP(index=0){if(index>=ipServices.length){console.error(
# Script to retrigger scripts if crashed
function trigger-script{
#$proc = Start-Process notepad.exe -Passthru
$proc = Start-Process Powershell.exe -argument "C:\Scripts\Script_Name.ps1 ScriptArugments" -Passthru
return $proc
}
function check-process{
[CmdletBinding()]
/**
* This method waits until page load is complete
* @author Naveenchandar
*
*/
public static void waitForJavascript(WebDriver driver) {
JavascriptExecutor js = (JavascriptExecutor) driver;
int maxlimit = 10 * 1000;
boolean load = false;
try {
import java.awt.Robot;
import java.awt.event.KeyEvent;
/** Press Esc Key using Robot class **/
public void pressEsc(WebDriver driver) {
try {
Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_ESCAPE);
robot.keyRelease(KeyEvent.VK_ESCAPE);
System.out.println("ESC Key pressed.");
@navchandar
navchandar / JoinSubreddits.js
Created December 26, 2019 05:32
Mini JS to subscribe to multiple sub reddits during account transfer
function sleep(ms){
return new Promise(resolve=>setTimeout(resolve,ms))
};
async function join(){
var i = 0;
for(i = 0; i < 100; i++){
document.getElementsByClassName('option active add login-required')[0].click();
await sleep(500);
}
@navchandar
navchandar / getElementsByXPath.js
Created October 28, 2019 10:29
Detect Elements by XPATH using pure JS
function getElementsByXPath(xpath, parent) {
let results=[];
let query = document.evaluate(xpath, parent||document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
for(let i = 0,length = query.snapshotLength;i < length;++i){
results.push(query.snapshotItem(i));
}
return results
};
items = getElementsByXPath("//*");
JavascriptExecutor js = (JavascriptExecutor) driver;
// Method 1
String scrollElementIntoMiddle = "var viewPortWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);" + "var viewPortHeight = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);" + "var elementTop = arguments[0].getBoundingClientRect().top;" + "var elementLeft = arguments[0].getBoundingClientRect().left;" + "jQuery('div').scrollTop(elementTop-(viewPortHeight/2));" + "jQuery('div').scrollLeft(elementLeft-(viewPortWidth/2));";
js.executeScript(scrollElementIntoMiddle, element);
// Method 2
String scrollElementWithVanillaJS = "arguments[0].scrollIntoView({behavior:\"smooth\", block:\"center\", inline:\"center\"});";
js.executeScript(scrollElementWithVanillaJS, element);
@navchandar
navchandar / WinUnlock.vbs
Created March 6, 2019 13:28
Delay Windows Lock by pressing F15 key every 5 seconds.
Set objShell = CreateObject("WScript.Shell")
X = objShell.Popup("Delay Windows Locking?", 10, "WinUnlock", vbYesNo)
Select Case X
Case vbYes
Do
objShell.SendKeys ("{F15}")
'MsgBox("Pressed F15 Key")
WScript.Sleep 5000
Loop
import java.util.concurrent.TimeUnit;
import java.io.File;
import java.io.FileInputStream;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public class ExcelRead {
public static void disableWarning() {
System.err.close();
System.setErr(System.out);
@navchandar
navchandar / balloontip.py
Last active January 1, 2017 11:36 — forked from wontoncc/balloontip.py
Balloon tip module, Python, using win32gui.
# -- coding: utf-8 --
from win32api import *
from win32gui import *
import win32con
import os
import time
class WindowsBalloonTip: