Skip to content

Adding ClickToLens #244

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions submissions/ClickToLens/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# ClickToLens

ClickToLens is a Chrome extension that allows you to quickly capture any with a right-click and analyze the image using various image search engines.

**Supported search engines:**

* Google Lens
* Yandex Images
* Bing Images
* TinEye

## Installation

1. Download the extension files from the repository.
2. Open Chrome and navigate to `chrome://extensions/`.
3. Enable "Developer mode" in the top right corner.
4. Click "Load unpacked" and select the directory containing the extension files.

## Usage

1. Right-click on any image.
2. Select "ClickToLens" from the context menu.
3. Choose the search engine you want to use to analyze the captured image.
4. The image will be automatically sent to the selected search engine, and the results will be displayed in a new tab.

## Contributing

Contributions are welcome! Please open an issue or submit a pull request.

## License

This project is licensed under the MIT License.
73 changes: 73 additions & 0 deletions submissions/ClickToLens/background.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
chrome.runtime.onInstalled.addListener(() => {
chrome.contextMenus.create({
id: "searchWithGoogleLens",
title: "Search with Google Lens",
contexts: ["image"]
});

chrome.contextMenus.create({
id: "searchOtherEnginesParent",
title: "Search with Other Engines",
contexts: ["image"]
});

chrome.contextMenus.create({
id: "searchBingImages",
title: "Bing Images",
parentId: "searchOtherEnginesParent",
contexts: ["image"]
});

chrome.contextMenus.create({
id: "searchYandexImages",
title: "Yandex Images",
parentId: "searchOtherEnginesParent",
contexts: ["image"]
});

chrome.contextMenus.create({
id: "searchTinEye",
title: "TinEye",
parentId: "searchOtherEnginesParent",
contexts: ["image"]
});
});

chrome.contextMenus.onClicked.addListener((info, tab) => {
if (info.menuItemId === "searchOtherEnginesParent") {
return;
}

const imageUrl = info.srcUrl;
let searchUrl = '';

if (!imageUrl) {
console.error("No image URL found for the clicked item.");
return;
}

switch (info.menuItemId) {
case "searchWithGoogleLens":
searchUrl = `https://lens.google.com/uploadbyurl?url=${encodeURIComponent(imageUrl)}`;
break;
case "searchBingImages":
searchUrl = `https://www.bing.com/images/search?view=detailv2&iss=SBI&form=SBIIRP&sbisrc=UrlPaste&q=imgurl:${encodeURIComponent(imageUrl)}`;
break;
case "searchYandexImages":
searchUrl = `https://yandex.com/images/search?url=${encodeURIComponent(imageUrl)}&rpt=imageview`;
break;
case "searchTinEye":
searchUrl = `https://tineye.com/search?url=${encodeURIComponent(imageUrl)}`;
break;
default:
console.error("Unknown menu item ID clicked:", info.menuItemId);
return;
}

if (searchUrl) {
chrome.tabs.create({
url: searchUrl,
index: tab.index + 1
});
}
});
Binary file added submissions/ClickToLens/icons/icon128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added submissions/ClickToLens/icons/icon16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added submissions/ClickToLens/icons/icon48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions submissions/ClickToLens/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"manifest_version": 3,
"name": "ClickToLens",
"version": "1.0",
"description": "Search any image with Google Lens and other search engines",
"permissions": [
"contextMenus"
],
"background": {
"service_worker": "background.js"
},
"icons": {
"16": "icons/icon16.png",
"48": "icons/icon48.png",
"128": "icons/icon128.png"
}
}