summaryrefslogtreecommitdiff
path: root/data/extensions/jsr@javascriptrestrictor/wrappingS-NP.js
diff options
context:
space:
mode:
Diffstat (limited to 'data/extensions/jsr@javascriptrestrictor/wrappingS-NP.js')
-rw-r--r--data/extensions/jsr@javascriptrestrictor/wrappingS-NP.js79
1 files changed, 55 insertions, 24 deletions
diff --git a/data/extensions/jsr@javascriptrestrictor/wrappingS-NP.js b/data/extensions/jsr@javascriptrestrictor/wrappingS-NP.js
index 018eaee..4bcd333 100644
--- a/data/extensions/jsr@javascriptrestrictor/wrappingS-NP.js
+++ b/data/extensions/jsr@javascriptrestrictor/wrappingS-NP.js
@@ -47,6 +47,19 @@
* These approaches are inspired by the algorithms created by [Brave Software](https://brave.com)
* available [here](https://github.com/brave/brave-core/blob/master/chromium_src/third_party/blink/renderer/modules/plugins/dom_plugin_array.cc).
*
+ * The purpose of the wrappers is solely to prevent fingerprinting. However,
+ * browsers modyfing the array stand out of the crowd, which makes them more
+ * fingerprintable. Consequently, JShelter does not modify an empty list. So
+ * no matter the configuration, an empty list is not populated by the wrappers.
+ *
+ * If PDF inline viewing is supported, Firefox returns 5 plugins:
+ * * "PDF Viewer"
+ * * "Chrome PDF Viewer"
+ * * "Chromium PDF Viewer"
+ * * "Microsoft Edge PDF Viewer"
+ * * "WebKit built-in PDF"
+ *
+ * A list containing exactly these plugins is treated as the empty list and it is not modified.
*/
/*
@@ -269,36 +282,54 @@
{
parent_object: "Navigator.prototype",
parent_object_property: "plugins",
- apply_if: "navigator.plugins.length > 0",
+ apply_if: "applyWrapper",
wrapped_objects: [],
helping_code:
methods + farbles + fakes +`
- var fp_prng = alea(domainHash, "S-NP");
- var plugins = navigator.plugins;
- var buffer = [];
- if(args[0]==0){
- for(var i = 0;i<plugins.length;i++){
- buffer.push(farblePlugin(plugins[i]), fp_prng);
- }
+ var applyWrapper = true; // Possibly overridden below
+ if (navigator.plugins.length === 0) {
+ applyWrapper = false;
}
- if(args[0]==1){
- for(var i = 0;i<plugins.length;i++){
- buffer.push(plugins[i]);
+ if (navigator.plugins.length === 5) {
+ let plugins = Array.prototype.reduce.call(
+ navigator.plugins,
+ function (acc, o) {acc.push(o.name); return acc;}, []);
+ if (plugins.includes("PDF Viewer") &&
+ plugins.includes("Chrome PDF Viewer") &&
+ plugins.includes("Chromium PDF Viewer") &&
+ plugins.includes("Microsoft Edge PDF Viewer") &&
+ plugins.includes( "WebKit built-in PDF")) {
+ applyWrapper = false; // See https://developer.mozilla.org/en-US/docs/Web/API/Navigator/plugins
}
- shuffleArray(buffer);
- }
- if(args[0]==0 || args[0]==1){
- var fakePlugin1 = fakePlugin(32, 16, 8);
- var fakePlugin2 = fakePlugin(31, 15, 7);
- buffer.push(fakePlugin1, fakePlugin2);
- shuffleArray(buffer);
- }
- var fakePluginArray = fakePluginArrayF(buffer);
- if(args[0]==1 || args[0]==2){
- var fakeMimeTypeArray = fakeMimeTypeArrayF([]);
}
- else {
- var fakeMimeTypeArray = fakeMimeTypeArrayF(fakePluginArray);
+ if (applyWrapper) {
+ var fp_prng = alea(domainHash, "S-NP");
+ var plugins = navigator.plugins;
+ var buffer = [];
+ if(args[0]==0){
+ for(var i = 0;i<plugins.length;i++){
+ buffer.push(farblePlugin(plugins[i], fp_prng));
+ }
+ }
+ if(args[0]==1){
+ for(var i = 0;i<plugins.length;i++){
+ buffer.push(plugins[i]);
+ }
+ shuffleArray(buffer);
+ }
+ if(args[0]==0 || args[0]==1){
+ var fakePlugin1 = fakePlugin(32, 16, 8);
+ var fakePlugin2 = fakePlugin(31, 15, 7);
+ buffer.push(fakePlugin1, fakePlugin2);
+ shuffleArray(buffer);
+ }
+ var fakePluginArray = fakePluginArrayF(buffer);
+ if(args[0]==1 || args[0]==2){
+ var fakeMimeTypeArray = fakeMimeTypeArrayF([]);
+ }
+ else {
+ var fakeMimeTypeArray = fakeMimeTypeArrayF(fakePluginArray);
+ }
}
`,
post_wrapping_code: [