Coder Social home page Coder Social logo

weisisheng / amazon-api-gateway-powered-browser-extension Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aws-samples/amazon-api-gateway-powered-browser-extension

1.0 1.0 0.0 108 KB

Deploy a browser extension powered by Amazon API Gateway and AWS Lambda

License: MIT No Attribution

JavaScript 100.00%

amazon-api-gateway-powered-browser-extension's Introduction

Browser Extension powered by Amazon API Gateway

This sample code allows you to quickly deploy a Firefox Extension that uses Serverless AWS Services as a backend. This example allows users to translate selected text on a loaded webpage.

The extension sends requests to an API Gateway which forwards them to a Lambda Function. The Lambda Function then translates the text using Amazon Translate and returns it to the user's browser to be displayed on screen.

Screenshot that demonstrates translating text on www.example.com from English to French

Architecture

Architecture diagram showing the Firefox Browser, an AWS account containing an API Gateway, a Lambda Function, and Amazon Translate

Requests are started in the Browser Extension. They then go through API Gateway to a Lambda Function. The Lambda function will submit the text for translation to Amazon Translate and will return the translated text back to the Browser through API Gateway.

Deployment

Clone this repository or download it as a .ZIP file

Backend

  1. In your AWS account, in CloudFormation, create a new stack and use the template file /aws_resources/template.yml
  2. When the stack is deployed, go to Outputs and make note of translateURL

Frontend (Firefox Extension)

  1. In the extension's background script, extension\background_script.js, replace the API Gateway URL on line 18.
  2. In your Firefox Browser, navigate to about:debugging
  3. On the side-bar on the left, select "This Firefox"
  4. Click on Load "Temporary Add-on..."
  5. Navigate to the directory where this repository was cloned, then select the file extension/manifest.json

Usage

Once the extension is loaded you should see an Orange border around any open webpages. This is a sign that the Extension was correctly loaded.

From any webpage (e.g. http://www.example.com/) highlight some text then right click on it and select "Translate selected text"

Screenshot showing example usage of the extension

The text should then be switched with its French equivalent.

Customization

To change the translation language, edit lines 66 and 67 in the file extension\background_script.js and change the source and destination language codes as needed.

To remove the orange border around the page content, edit the file extension\content_script.js and delete the last line.

Security

See CONTRIBUTING for more information.

License

This library is licensed under the MIT-0 License. See the LICENSE file.

amazon-api-gateway-powered-browser-extension's People

Contributors

amazon-auto avatar odaymansour avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.