Skip to content

Commit

Permalink
Expose information about @resources in GM_info.
Browse files Browse the repository at this point in the history
Fixes #1610
  • Loading branch information
arantius committed Sep 20, 2012
1 parent 01cb1d4 commit d4007d9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
9 changes: 8 additions & 1 deletion modules/script.js
Expand Up @@ -461,6 +461,13 @@ Script.prototype.info = function() {
for (var i = 0, m = null; m = this.matches[i]; i++) {
matches[matches.length] = m.pattern;
}
var resources = {};
for (var i = 0, r = null; r = this.resources[i]; i++) {
resources[r.name] = {
'name': r.name,
'mimetype': r.mimetype,
};
}
return {
'uuid': this.uuid,
'version': gGreasemonkeyVersion,
Expand All @@ -474,7 +481,7 @@ Script.prototype.info = function() {
'name': this.name,
'namespace': this.namespace,
// 'requires': ???,
// 'resources': ???,
'resources': resources,
'run-at': this.runAt,
'version': this.version,
},
Expand Down
9 changes: 9 additions & 0 deletions modules/scriptDependency.js
Expand Up @@ -52,6 +52,15 @@ function ScriptDependency_getFilename() {
return '' + (this._filename || this._dataURI || '');
});

ScriptDependency.prototype.__defineGetter__('mimetype',
function ScriptDependency_getMimetype() {
var mimetype = this._mimetype;
if (this._charset && this._charset.length > 0) {
mimetype += ';charset=' + this._charset;
}
return mimetype;
});

ScriptDependency.prototype.__defineGetter__('name',
function ScriptDependency_getName() { return '' + this._name; });

Expand Down
7 changes: 1 addition & 6 deletions modules/scriptResource.js
Expand Up @@ -14,11 +14,6 @@ ScriptResource.prototype.__defineGetter__('dataContent',
function ScriptResource_getDataContent() {
var binaryContents = GM_util.getBinaryContents(this.file);

var mimetype = this._mimetype;
if (this._charset && this._charset.length > 0) {
mimetype += ';charset=' + this._charset;
}

return 'data:' + mimetype
return 'data:' + this.mimetype
+ ';base64,' + encodeURIComponent(btoa(binaryContents));
});

0 comments on commit d4007d9

Please sign in to comment.