Chrome plug-in development --------- convert the URL into a QR code website2QRcode, chrome QR code plug-in
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}
Popup.html:
<!DOCTYPE html>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 );});});
Result:
If you have any good links, scan and share them directly.
Source Code address: https://github.com/iloster/WebSite2QRcode