Skip to content

Commit

Permalink
fix(injection): improve plugin spoofing; #366
Browse files Browse the repository at this point in the history
  • Loading branch information
sereneblue committed May 12, 2020
1 parent 14b4678 commit e75d7c8
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions src/lib/inject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,20 +246,30 @@ class Injector {
const pluginArray = []
injProp.value.forEach(p => {
function FakePlugin () { return p }
const plugin = new FakePlugin()
const plugin = new FakePlugin();
Object.setPrototypeOf(plugin, Plugin.prototype);
pluginArray.push(plugin)
})
pluginArray.__proto__.item = function item() {
return this[arguments[0]];
};
pluginArray.__proto__.namedItem = function namedItem() {
return this.find(p => p.name === arguments[0]);
};
pluginArray.__proto__.refresh = function item() {
return;
};
return pluginArray
Object.defineProperty(pluginArray, 'item', {
configurable: false,
value: function item() {
return this[arguments[0]];
}
});
Object.defineProperty(pluginArray, 'namedItem', {
configurable: false,
value: function namedItem() {
return this.find(p => p.name === arguments[0]);
}
});
Object.defineProperty(pluginArray, 'refresh', {
configurable: false,
value: function refresh() {
return;
}
});
return pluginArray;
})();
Object.defineProperty(window.navigator, 'plugins', {
Expand Down

0 comments on commit e75d7c8

Please sign in to comment.