{"id":1344,"date":"2022-08-30T15:15:45","date_gmt":"2022-08-30T15:15:45","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/10\/faking-flash-plugin-info-in-phantomjs-1-8-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:15:45","modified_gmt":"2022-08-30T15:15:45","slug":"faking-flash-plugin-info-in-phantomjs-1-8-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/faking-flash-plugin-info-in-phantomjs-1-8-collection-of-common-programming-errors\/","title":{"rendered":"Faking flash plugin info in phantomjs 1.8-Collection of common programming errors"},"content":{"rendered":"<p>I&#8217;m a newbie to PhantomJs. I&#8217;m using 1.8.1 version. I&#8217;ve looked at here to solve this as i&#8217;ve similar requirement.<\/p>\n<p>I&#8217;m doing something like this:<\/p>\n<pre><code>page.onInitialized = function () {\n    page.evaluate(function () {\n        (function () {\n            window.navigator.plugins = {\n                'length': 1, \n                'Shockwave Flash': {\n                    'description':'fakeflash'\n                }\n            };\n        })();\n    });\n};\n<\/code><\/pre>\n<p>When i do console.log (window.navigator.plugins[&#8216;Shockwave Flash&#8217;].description)<\/p>\n<p>I get undefined as the result.<\/p>\n<p>Could anyone tell me what am doing wrong?<\/p>\n<ol>\n<li>\n<p>Replace the entire <code>navigator<\/code> object (you can&#8217;t just modify some properties).<\/p>\n<pre><code>var page = require('webpage').create();\n\npage.onConsoleMessage = function (msg) {\n    console.log(msg);\n};\n\npage.onInitialized = function () {\n    page.evaluate(function () {\n        window.navigator = {\n            plugins: {\n                length: 1,\n                'Shockwave Flash': {\n                    description: 'fakeflash'\n                }\n            }\n        };\n    });\n};\n\npage.content = 'Hello';\npage.evaluate(function () {\n    console.log(window.navigator.plugins['Shockwave Flash'].description);\n});\n\nphantom.exit();\n<\/code><\/pre>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2013-11-10 03:08:45. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I&#8217;m a newbie to PhantomJs. I&#8217;m using 1.8.1 version. I&#8217;ve looked at here to solve this as i&#8217;ve similar requirement. I&#8217;m doing something like this: page.onInitialized = function () { page.evaluate(function () { (function () { window.navigator.plugins = { &#8216;length&#8217;: 1, &#8216;Shockwave Flash&#8217;: { &#8216;description&#8217;:&#8217;fakeflash&#8217; } }; })(); }); }; When i do console.log (window.navigator.plugins[&#8216;Shockwave [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1344","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1344","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1344"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1344\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1344"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1344"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1344"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}