Synzvato / decentraleyes

This repository has a new home: https://git.synz.io/Synzvato/decentraleyes
Mozilla Public License 2.0
1.45k stars 108 forks source link

BuiltWith serves detailed library usage statistics #144

Open Anton-Latukha opened 7 years ago

Anton-Latukha commented 7 years ago

About: "To keep this add-on from turning into bloatware, it's important to find out which versions of which libraries are most commonly used on websites, so that less popular resources can be removed from the default bundle."

I found https://builtwith.com as most informative platform. It has overall sites statistics and library-oriented also. Check-out https://trends.builtwith.com/javascript/jQuery, they have version statistics there also.

This site has extensive information and features. If you register - dashboard with even more features going to open - there checkout 'Reports' and there 'Modify' tab.

On builtwith lib info sorted by version number. Case 1: sort them by usage Case 2: display only ones that used more than in 500,000 of sites

As a user-side script and throw it info GreaseMonkey.

I started to do selection:

function getElementsByStyle(prop, val) {

  /*
  * Example usage:
  *   getElementsByStyle('color', 'rgb(0, 0, 0)')
  *
  */

  var matched = [];

  [].forEach.call(document.querySelectorAll('*'), function(node) {

    if (getComputedStyle(node)[prop] == val) {
      matched.push(node);
    }

  });

  return matched;
}

var version_list_block = document.getElementById("mainform")
  .getElementsByTagName("div")
  .getElementsByClassName("container")
  .getElementsByTagName("div")
  .getElementsByClassName("row")
  .getElementsByTagName("div")
  .getElementsByClassName("span4")
  .getElementsByStyle("height", "300px")
  .getElementsByStyle("overflow", "auto");
var version_list = version_list_block
  .getElementsByClassName("row")
  .getElementsByStyle("margin-top", "5px");

but I can't figure-out how to reorder div's inside div using \<p> text values.

I also found snippet: https://jsfiddle.net/hibbard_eu/C2heg/, but it is not really understandable for me.

Hope I was in some help for you.

TriMoon commented 7 years ago

You should have linked to a URL with the data your script acts upon. Without that i'm unable to help in anyway, it's already hard to tell what you wanted...

To reorder HTML tags using DOM, you need to insert/append the DOM-Node into it's place and afterwards remove it from its old position....

Synzvato commented 7 years ago

@Anton-Latukha Many thanks a lot for the suggestion! I'll definitely be taking a look at BuiltWith to see if we can combine their metrics with the W3Techs metrics we currently use.

Anton-Latukha commented 7 years ago

Thank you so much.

It is concept code. It is about link in text: [https://trends.builtwith.com/javascript/jQuery], and it's section "Version Specific Reports". Parsing version/usage data from it, sort it in usage order. That it can be put in GreaseMobkey, or Chrome version, and it going to sort things for you automatically on opening Builtwith pages.

Than it also can be used "automagically" (done by hands) to use in a crawler, but that probably an overkill for the task.