本地网页出现陌生注入代码,求识别及Shockwave Flash相关疑问解答
问题解答
这段代码是什么?
你看到的这段代码是Ruffle模拟器的插件模拟脚本,作用是让浏览器识别“存在Shockwave Flash插件”,以此兼容依赖Flash的网页内容。
它具体做了这些事:
- 定义了模仿浏览器插件和MIME类型的类(
RuffleMimeType、RufflePlugin等) - 创建模拟的Shockwave Flash插件实例,包含Flash对应的所有MIME类型(比如
application/x-shockwave-flash对应SWF文件) - 修改
navigator.plugins和navigator.mimeTypes对象,让浏览器认为Flash插件已安装,触发Ruffle加载SWF内容
完整代码如下:
(function(){class RuffleMimeType{constructor(a,b,c){this.type=a,this.description=b,this.suffixes=c}}class RuffleMimeTypeArray{constructor(a){this.__mimetypes=[],this.__named_mimetypes={};for(let b of a)this.install(b)}install(a){let b=this.__mimetypes.length;this.__mimetypes.push(a),this.__named_mimetypes[a.type]=a,this[a.type]=a,this[b]=a}item(a){return this.__mimetypes[a]}namedItem(a){return this.__named_mimetypes[a]}get length(){return this.__mimetypes.length}}class RufflePlugin extends RuffleMimeTypeArray{constructor(a,b,c,d){super(d),this.name=a,this.description=b,this.filename=c}install(a){a.enabledPlugin||(a.enabledPlugin=this),super.install(a)}}class RufflePluginArray{constructor(a){this.__plugins=[],this.__named_plugins={};for(let b of a)this.install(b)}install(a){let b=this.__plugins.length;this.__plugins.push(a),this.__named_plugins[a.name]=a,this[a.name]=a,this[b]=a}item(a){return this.__plugins[a]}namedItem(a){return this.__named_plugins[a]}get length(){return this.__plugins.length}}const FLASH_PLUGIN=new RufflePlugin("Shockwave Flash","Shockwave Flash 32.0 r0","ruffle.js",[new RuffleMimeType("application/futuresplash","Shockwave Flash","spl"),new RuffleMimeType("application/x-shockwave-flash","Shockwave Flash","swf"),new RuffleMimeType("application/x-shockwave-flash2-preview","Shockwave Flash","swf"),new RuffleMimeType("application/vnd.adobe.flash-movie","Shockwave Flash","swf")]);function install_plugin(a){navigator.plugins.install||Object.defineProperty(navigator,"plugins",{value:new RufflePluginArray(navigator.plugins),writable:!1}),navigator.plugins.install(a),0<a.length&&!navigator.mimeTypes.install&&Object.defineProperty(navigator,"mimeTypes",{value:new RuffleMimeTypeArray(navigator.mimeTypes),writable:!1});for(var b=0;b<a.length;b+=1)navigator.mimeTypes.install(a[b])}install_plugin(FLASH_PLUGIN);})();
为何现在还有人使用Shockwave、Flash或SWF?
- 遗留系统依赖:很多企业内部管理工具、政府公共服务系统、老工业控制界面基于Flash开发,重构需要大量资金和时间,短期内无法替换,只能继续依赖Flash运行环境。
- 怀旧内容需求:早期Flash小游戏、动画短片、互动课件是不少人的回忆,爱好者通过Ruffle这类模拟器重温这些内容,相关社区和资源仍有活跃度。
- 特定专业场景:部分设计、教育领域的老工具或课件未完成更新,比如早期交互式教学内容、设计原型,暂时仍需要Flash支持。
内容的提问来源于stack exchange,提问作者James V. Fields
相关产品推荐
相关产品推荐

