NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript==
// @name Add to Chrome
// @version 1.0.1
// @description Convert Chrome extension links to download extension from page.
// @author celliott1997
// @include *
// @require https://code.jquery.com/jquery-3.1.1.min.js
// @grant none
// ==/UserScript==
(function() {
'use strict';
function create(Element){return $(document.createElement(Element));}
var webstore = "https://chrome.google.com/webstore/detail/";
$(document).ready(function(){
$("a[href]").each(function(){
var button = $(this);
var linkUrl = button.attr("href");
var appId = linkUrl.substring(linkUrl.lastIndexOf("/")+1);
if (linkUrl.indexOf(webstore) > -1){
create("link").attr("rel", "chrome-webstore-item").attr("href", webstore+appId)
.appendTo(document.head);
button.click(function(evt){
evt.preventDefault();
chrome.webstore.install();
return false;
});
}
});
});
})();