The browser cannot enter the link, only by scanning the QR code to achieve. But sometimes see an interesting site, want to share, you have to first to turn the link into a QR code site. Turn it into a QR code first. Scan again. A little trouble. So write a plugin. Generate two-dimensional code directly.
Files that need to be referenced: jquery.qrcode.js (convert text to QR code) and jquery
With the browser actions implementation. The user clicks the icon. Displays the QR code in the popup.html code, such as the following:
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:watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvawxvc3rlcg==/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/southeast ">
What are the good links, direct scan sharing just fine
Source code Address: Https://github.com/iloster/WebSite2QRcode
Chrome Plugin Development-----------convert URLs to QR code Website2qrcode