The browser can not enter the link, only by scanning the two-dimensional code to achieve, but sometimes see an interesting site, want to share, but also first to the link into a two-dimensional code of the site, first turned into two-dimensional code, and then scan, a little trouble. So write a plug-in, directly generate two-dimensional code.
Files to be referenced: jquery.qrcode.js (convert text to QR code) and jquery
With the browser actions implementation, the user click on the icon, in the popup.html display QR code, the code is as follows:
Manifest.json:
{ "name": "Website2qrcode", "version": "1.0", "description": "Translate URL into QR code", "Browser_action": { "Default_icon": "Icon.png", "Default_title": "QRCode", "Default_popup": "Popup.html" }, " Permissions ": [ " tabs ", " http://*/* ", " https://*/* ", " notifications " ], " Manifest_ Version ": 2
Popup.html:
<! DOCTYPE html>
Popup.jsfunction Getcurrenttaburl (callback) {//Gets the URL and title of the current tag chrome.tabs.getSelected (function (tab) {var taburl = Tab.url;var Tabtitle = Tab.title;callback (Taburl,tabtitle);}); Listen for the click Time Document.addeventlistener (' domcontentloaded ', function () {Getcurrenttaburl (function (taburl,tabtitle) { var website = document.getElementById (' website '); var title = document.getElementById (' title '); website.textcontent = "URL:" + taburl; Title.textcontent = "title:" + Tabtitle; Generate a two-dimensional code jQuery (' #QRcode '). QRCode (TabURL);});
Results:
What are the good links, direct scan sharing just fine
Source Address: Https://github.com/iloster/WebSite2QRcode
Chrome Plugin Development-----------convert URLs to QR code website2qrcode