DEV Community

Dr. House
Dr. House

Posted on

1 2

[utility script] functionally replace Devtools 'Copy JS path' with 'Copy jQuery path'

When working with jQuery on webpages, I regularly use the Devtools context menu option 'Copy JS path', this produces something like:

document.querySelector('element1 > element2')

then I always need to replace 'document.querySelector' with a '$' for jQuery to work... so tedious!

I wrote a small Autohotkey utility script which detects 'document.querySelector' when in the clipboard and automatically replaces it with a '$' - it's very simple and effective.

install Authotkey, save as 'clippie.ahk' (for example):

#Persistent
OnClipboardChange("ClipChanged")
return

ClipChanged(Type) {
StringReplace, clipboard, clipboard, document.querySelector, $, All
}

(minor note: if you ever need to copy/paste 'document.querySelector', just copy/paste 'document.querySelecto' and then manually add 'r' at the end)

Or, if you're brave, I compiled the script into an .exe you can download:
clippie - Copy jQuery path

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (0)

Billboard image

Try REST API Generation for Snowflake

DevOps for Private APIs. Automate the building, securing, and documenting of internal/private REST APIs with built-in enterprise security on bare-metal, VMs, or containers.

  • Auto-generated live APIs mapped from Snowflake database schema
  • Interactive Swagger API documentation
  • Scripting engine to customize your API
  • Built-in role-based access control

Learn more

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay