Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yarosj/crossdomain-selector
Retrieves a selector from another site by a screenshot
https://github.com/yarosj/crossdomain-selector
crossdomain puppeteer screenshot selector
Last synced: about 1 month ago
JSON representation
Retrieves a selector from another site by a screenshot
- Host: GitHub
- URL: https://github.com/yarosj/crossdomain-selector
- Owner: YarosJ
- License: mit
- Created: 2018-11-09T12:13:37.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-09-03T07:05:34.000Z (over 4 years ago)
- Last Synced: 2024-11-30T20:08:46.009Z (about 1 month ago)
- Topics: crossdomain, puppeteer, screenshot, selector
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/crossdomain-selector
- Size: 31.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# README
This package allows you to get an element selector from another site using the screenshot, which is not possible with a cross-domain iframe due to browser security restrictions.
## Usage
Import package:
import { makeScreenshot, getSelector } from 'crossdomain-selector';
Make screenshot:
const base64Screenshot = await makeScreenshot({ site: 'https://www.npmjs.com' });
Then you can display this screenshot on the client and get click coordinates on an screenshot with something like this:
recivedBase64Image = ''
{
const coordinates = {
x: e.pageX - e.target.offsetLeft,
y: e.pageY - e.target.offsetTop,
};
// Send on server coordinates
}}/>Now you can get a selector on the received coordinates on the server:
const selector = await getSelector({
site: 'https://www.npmjs.com', // Site to get selector
coordinates: [50, 120], // Received from the client
});## Docker
If you use Docker you need to pass it in params:
makeScreenshot({
...
docker: true,
});getSelector({
...
docker: true,
});Important! [You should read this to make proper dockerfile](https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md#running-on-alpine)
## License
MIT License. Copyright 2018 Yaroslaw Zhuk
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.