Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use cases for `@includes` and `@matches` in scripts. #1333

Closed
Sxderp opened this issue Feb 23, 2018 · 5 comments

Comments

Projects
None yet
3 participants
@Sxderp
Copy link

commented Feb 23, 2018

I posted a request on the usersScript API bugzilla about adjusting how @include and @match work (allow "OR") and they've asked for additional information regarding use cases. I suspect the majority of use cases, where both are used, have to do with the ability to use RegExp in @include but nevertheless, it would be great if some sort of details or statics could be provided on how scripts are currently using the fields. Any additional input is appreciated.

Bugzilla Link: https://bugzilla.mozilla.org/show_bug.cgi?id=1437098#c2

@Martii

Cross posted on greasyfork repo. JasonBarnabe/greasyfork#536

Check out greasemonkey/greasemonkey#2663 for various additional details.

@sizzlemctwizzle

This comment has been minimized.

Copy link
Member

commented Feb 23, 2018

We could provide you with statistics or we could just give you the user script metadata for all user scripts on OUJS in JSON format. That might be of more use to you since you could preform any kind of analysis you want on the metadata yourself.

Anyway, it's up to @Martii on how he wants to provide the data.

@Sxderp

This comment has been minimized.

Copy link
Author

commented Feb 24, 2018

Either would work. Though having all the meta data would be nice.

@Martii

This comment has been minimized.

Copy link
Member

commented Feb 24, 2018

Collected meta for the UserScript (and OpenUserJS) metadata block and no libraries:

collected_meta.json.zip

Actual metadata is larger because we don't collect everything but you'll have @include and @match values to twiddle with. Hitting the storage to regenerate for say @history, which has been seen on occasion, could get huge and tie up bandwidth. Data URI's are big enough and those are included for @icon and such. We currently collect at that block here with the same format as later GM3.x

As an Author myself I usually include the basic globs and then some depending on if a regular expression (re) is warranted... I even found TrixieSetup.msi in the archives the other day in which re's aren't supported and neither is @match since that was before scripting in Chrome/Chromium.

Typically I see Chrome/Chromium Authors use @match and GM Authors use @include but there are exceptions.


Don't mind this... if my local storage medium croaks again and my backups fail like they did... it's here for reference:

hook (full)

// Dump collected (specific optional) metadata
var fs = require('fs');
var async = require('async');
var Script = require('./models/script').Script;
Script.find(
  {
    isLib: false
//     , 'meta.UserScript.include': { $exists: true }
//     , 'meta.UserScript.match': { $exists: true }

  }, function (aErr, aScripts) {
    var metas = [];

    if (aErr || !aScripts) {
      console.warn('no scripts found');
      return;
    }

    async.each(aScripts, function (aScript, aEachCallback) {
      metas.push(aScript.meta);

      process.nextTick(function () { aEachCallback(); }); // breathe
    }, function (aErr) {

      fs.writeFile('/home/user/collected_meta.json', JSON.stringify(metas, null, ' '), function (aErr) {
        if (aErr) {
          console.warn('error writing');
          return;
        }
        console.log('written');
      });
    });

  });

strong filter (snip and unordered)

Script.find(
  {
    isLib: false
    , 'meta.UserScript.include': { $exists: true }
    , 'meta.UserScript.match': { $exists: true }

  }, [ 'meta.UserScript.include', 'meta.UserScript.match', 'meta.UserScript.name' ], function (aErr, aScripts) {
    var metas = [];

@Sxderp

This comment has been minimized.

Copy link
Author

commented Feb 26, 2018

Hey thanks a lot. The archive has provided some interesting insights.

@Sxderp Sxderp closed this Feb 26, 2018

@Martii

This comment has been minimized.

Copy link
Member

commented Feb 26, 2018

You are welcome and welcome anytime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.