Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 7th, 2012  |  syntax: None  |  size: 1.50 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. // ==UserScript==
  2. // @name          View Add-on Compatibility Reports
  3. // @namespace     http://userscripts.org/scripts/show/61398
  4. // @version       0.1
  5. // @description   Adds a link to add-on compatibility reports to addons.mozilla.org.
  6. // @include       https://addons.mozilla.org/*
  7. // @include       https://preview.addons.mozilla.org/*
  8. // @author        http://userscripts.org/users/fcp
  9. // @license       This program is in the public domain.
  10. // ==/UserScript==
  11.  
  12. void function(){
  13.   function encodeAsFormValue(s)
  14.   {
  15.     return s.replace(/[\x00-\x1F!\"#\$%&\'\(\)\*\+,\/\:;<=>\?@\[\\\]\^`\{\|\}]/g, function(str){
  16.       var code = str.charCodeAt(0);
  17.       if (code <= 0x0F)
  18.         return '%0' + code.toString(16).toUpperCase();
  19.       else
  20.         return '%' + code.toString(16).toUpperCase();
  21.     }).replace(/ /g, '+');
  22.   }
  23.  
  24.   var found = location.href.match(/^https:\/\/[^\/]+\/([^\/?#]+)\/([^\/?#]+)\/addon\/.*\/?$/);
  25.   if (!found)
  26.     return;
  27.   var lang = found[1];
  28.   var application = found[2];
  29.   let button = document.querySelector("#addon-summary .install-button a");
  30.   if (!button) return;
  31.   var addonid = button.href.match(/\d+/).toString();
  32.  
  33.   var parent = button.parentNode.parentNode.parentNode
  34.   var div = parent.appendChild(document.createElement("div"));
  35.   var a = div.appendChild(document.createElement('a'));
  36.   a.href = '/' + lang + '/' + application + '/compatibility/reporter?guid=' + encodeAsFormValue(addonid);
  37.   a.className = "button";
  38.   a.appendChild(document.createTextNode('View compatibility reports'));
  39. }();