-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1dabf0f
commit 3a34888
Showing
4 changed files
with
70 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!-- | ||
This Source Code Form is subject to the terms of the Mozilla Public | ||
License, v. 2.0. If a copy of the MPL was not distributed with this | ||
file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
--> | ||
|
||
<html> | ||
<head> | ||
<link rel="stylesheet" href="color.css"> | ||
</head> | ||
<body style="height: 100vh;font-family: sans-serif;"> | ||
<div id="search_on_google_lens_elem" style="position: fixed; text-align: center; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.6); z-index: 1000000;"> | ||
<div style="position: absolute; top: 50%; left: 50%; color: white; transform: translate(-50%, -50%); font-size: 50px; white-space: nowrap;"> | ||
<img style="width: 60px; height: 60px;" src="/loading.svg"></img> | ||
<div class="i18n-text" data-i18n-id="sendingImage"></div> | ||
</div> | ||
</div> | ||
<script src="l10n.js"></script> | ||
<script type="module" src="./post_to_lens.mjs"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
(async () => { | ||
const params = new URLSearchParams(window.location.search); | ||
const image_data_url = decodeURIComponent(params.get("image_data_url") ?? ""); | ||
if (!image_data_url) { | ||
return; | ||
} | ||
|
||
const container = document.createElement("div"); | ||
container.style.display = "none"; | ||
document.body.appendChild(container); | ||
|
||
const form = document.createElement("form"); | ||
form.action = `https://lens.google.com/v3/upload?ep=ccm&s=&st=${Date.now()}`; | ||
form.method = "POST"; | ||
form.enctype = "multipart/form-data"; | ||
// form.target = "_blank"; | ||
container.appendChild(form); | ||
|
||
const file_input = document.createElement("input"); | ||
file_input.type = "file"; | ||
file_input.name = "encoded_image"; | ||
form.appendChild(file_input); | ||
|
||
const pid_input = document.createElement("input"); | ||
pid_input.type = "text"; | ||
pid_input.name = "processed_image_dimensions"; | ||
pid_input.value = "1000,1000"; | ||
|
||
const result = await fetch(image_data_url); | ||
const file = new Blob([await result.arrayBuffer()]); | ||
const data_transfer = new DataTransfer(); | ||
const file_obj = new File([file], "image.jpg", { type: "image/jpeg" }); | ||
data_transfer.items.add(file_obj); | ||
file_input.files = data_transfer.files; | ||
|
||
form.submit(); | ||
|
||
container.remove(); | ||
})(); |