Chrome plug-in development --------- convert the URL into a QR code website2QRcode

Source: Internet
Author: User

Chrome plug-in development --------- convert the URL into a QR code website2QRcode

The self-built browser cannot enter a link. It can only be implemented by scanning the QR code. However, if you want to share an interesting website, you have to convert the link into a QR code first, scanning again is a little troublesome. So I wrote a plug-in to generate a QR code directly.

Files to be referenced: jquery. qrcode. js (convert text into QR code) and jquery

The Browser actionsis used. The user clicks the icon and displays the QR code in popup.html. The Code is as follows:

Manifest. json:

{"Name": "WebSite2QRcode", "version": "1.0", "description": "convert a URL into a QR code", "browser_action": {"default_icon ": "icon.png", "default_title": "QRcode", "default_popup": "popup.html"}, "permissions": ["tabs", "http ://*/*", "https: // */*", "communications"], "manifest_version": 2}

Website2QRcode<script src="jquery-2.1.3.min.js"></script><script type="text/javascript" src="jquery.qrcode.min.js"></script><script type="text/javascript" src="popup.js"></script>

Popup. js

Function getCurrentTabUrl (callback) {// obtain the URL and title chrome of the current tag. tabs. getSelected (function (tab) {var tabUrl = tab. url; var tabTitle = tab. title; callback (tabUrl, tabTitle) ;}/// specifies the time when a document is clicked. addEventListener ('domainloaded', function () {getCurrentTabUrl (function (tabUrl, tabTitle) {var website = document. getElementById ('website'); var title = document. getElementById ('title'); website. textContent = "url:" + tabUrl; title. textContent = "title:" + tabTitle; // generate the QR code jQuery ('# qrcode '). qrcode (tabUrl );});});

Source Code address:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.