source: ipk/source.arm/playersnp_hbbtv/_path_/usr/local/share/titan/plugins/hbbtv/opera/opera_home/browser.js @ 39499

Last change on this file since 39499 was 39499, checked in by gost, 7 years ago

add arm plugins

File size: 41.3 KB
Line 
1// VdxKWub7+VJKsPL2r7C7Ot/543aX6GALKciB83klyETb4QNK5jDEruvyBpEnNxhhoFTwrSStojibz9orWfyaUNKC23Ox4OrcIPqev4fjpdNX5iY/FXwMihY/TspovcnJ9bJvWt+ZOCzYZpa/rXjMLofZh7Qfn/ufGD2efoS+SIEZr4kDMWjgQutZ5sW0Y6wNPIprxo5rSRGfOdc7vbbKGLUL90lxwvptLssqYjCScQcF8pc27IeA7yHSQe8LOcCtfLIoypvpG0oYqFOXJLDCfC4AmZ5GGuz8lstHGNWVqOu8IjbaNaqQsf33mLHelft24ka17ilOlBBc2GTOAQ+dBA==
2/**
3** Copyright (C) 2000-2011 Opera Software AS.  All rights reserved.
4**
5** This file is part of the Opera web browser.
6**
7** This script patches sites to work better with Opera
8** For more information see http://www.opera.com/docs/browserjs/
9**
10** If you have comments on these patches (for example if you are the webmaster
11** and want to inform us about a fixed site that no longer needs patching) please
12** report issues through the bug tracking system
13** https://bugs.opera.com/
14**
15** DO NOT EDIT THIS FILE! It will not be used by Opera if edited.
16**/
17// Generic fixes (mostly)
18(function(opera){
19        if(!opera || (opera&&opera._browserjsran))return;
20        opera._browserjsran=true;
21        var bjsversion=' Opera Linux SDK 3700 core , March 9, 2011 ';
22        // variables and utility functions
23        var navRestore = {}; // keep original navigator.* values
24        var shouldRestore = false;
25        var hostname = location.hostname; // caching some strings for performance
26        var href = location.href;
27        var pathname=location.pathname;
28        var fixed = false; // magic fixes need only run once
29        if(!opera.postError)opera.postError=function(){}; // handling versions w/o error console
30        // Storing function references
31        var postError = opera.postError,
32        call = Function.prototype.call,
33        indexOf=String.prototype.indexOf,
34        lastIndexOf=String.prototype.lastIndexOf,
35        replace=String.prototype.replace,
36        match=String.prototype.match,
37        toLowerCase=String.prototype.toLowerCase,
38        getAttribute=Element.prototype.getAttribute,
39        setAttribute=Element.prototype.setAttribute,
40        insertBefore=Node.prototype.insertBefore,
41        insertAdjacentHTML=Element.prototype.insertAdjacentHTML,
42        defineMagicVariable=opera.defineMagicVariable,
43        defineMagicFunction=opera.defineMagicFunction,
44        version=opera.version,
45        getElementById=Document.prototype.getElementById,
46        appendChild=Node.prototype.appendChild,
47        removeChild=Node.prototype.removeChild,
48        replaceChild=Node.prototype.replaceChild,
49        evaluate=Document.prototype.evaluate,
50        getElementsByTagName=Document.prototype.getElementsByTagName,
51        createElement=Document.prototype.createElement,
52        createEvent=Document.prototype.createEvent,
53        dispatchEvent=Document.prototype.dispatchEvent,
54        initEvent=Event.prototype.initEvent,
55        createTextNode=Document.prototype.createTextNode,
56        stopPropagation=Event.prototype.stopPropagation,
57        preventDefault=Event.prototype.preventDefault,
58        getComputedStyle=window.getComputedStyle,
59        slice=Array.prototype.slice,
60        shift=Array.prototype.shift,
61        setTimeout=window.setTimeout,
62        removeAttribute=Element.prototype.removeAttribute,
63        addEventListener=Document.prototype.addEventListener,
64        isNaN=window.isNaN,
65        RegExp=window.RegExp,
66        unescape=window.unescape,
67        func_toString=Function.prototype.toString,
68        parseFloat=window.parseFloat,
69        random=Math.random;
70        var opera_version = parseFloat.call(window,opera.version());
71        var tinyMCEVersionInfo={};
72
73
74        // Utility functions
75
76        function addCssToDocument(cssText, doc, mediaType){
77                getElementsByTagName.call=addEventListener.call=createElement.call=createTextNode.call=insertBefore.call=setAttribute.call=appendChild.call=version.call=call;
78                doc = doc||document;
79                mediaType = mediaType||'';
80                addCssToDocument.styleObj=addCssToDocument.styleObj||{};
81                var styles = addCssToDocument.styleObj[mediaType];
82                if(!styles){
83                        var head = getElementsByTagName.call(doc, "head")[0];
84                        if( !head ){
85                                var docEl = getElementsByTagName.call(doc, "html")[0];
86                                if(!docEl){
87                                        // :S this shouldn't happen - see if document hasn't loaded
88                                        addEventListener.call(doc, opera&&version.call(opera)>=9?'DOMContentLoaded':'load',
89                                        function(){ addCssToDocument(cssText, doc); },false);
90                                        return;
91                                }
92                                head = createElement.call(doc, "head");
93                                if(head) insertBefore.call(docEl, head,docEl.firstChild);
94                                else head = docEl;
95                        }
96                        addCssToDocument.styleObj[mediaType] = styles = createElement.call(doc, "style");
97                        setAttribute.call(styles, "type","text/css");
98                        if(mediaType)setAttribute.call(styles, "media", mediaType);
99                        appendChild.call(styles, createTextNode.call(doc,' '));
100                        appendChild.call(head, styles)
101                }
102                styles.firstChild.nodeValue += cssText+"\n";
103                return true;
104        }
105
106        function addPreprocessHandler( search, replacement, onceonly, conditional ){
107                // adding event handler for script pre-processing if required
108                var handler=function(e){
109                        indexOf.call=replace.call=removeEventListener.call=call; /* also needs anything used inside conditional! */
110                        if( conditional && ! conditional(e.element) ){return;}
111                        e.element.text=replace.call( e.element.text, search, replacement );
112                        if(onceonly){
113                                removeEventListener.call(opera, 'BeforeScript', arguments.callee, false);
114                        }
115                }
116                opera.addEventListener('BeforeScript', handler , false);
117                return handler;
118        }
119
120function avoidDocumentWriteAbuse(contentRegexp){
121        var dw=document.write;
122        contentRegexp = contentRegexp || /(^<img .*?width=("|)1("|)\s+height=("|)1("|)\s+border=("|)0("|)\s+alt="".*?>$|^\[object Object\]$)/i;
123        document.write=function( s ){
124                if( String(s).match( contentRegexp ) ){
125                        opera.postError('Warning: scripts on '+window.location+' were changed by the s_code patch. See browser.js for details.');
126                }else{//opera.postError(arguments);
127                        dw.apply(document, arguments);
128                }
129        };
130}
131        function fakeCSSFilters(){ // faking support for some of the common filters so that using them won't stop the script
132                var filterObj={apply:function(){}, play:function(){}, Apply:function(){}, Play:function(){}}; // some of the common functions
133                HTMLElement.prototype.filters=[ filterObj, filterObj, filterObj ]; // fake three applied filters with play and apply functions
134                HTMLElement.prototype.filters['blendTrans']=filterObj; // we also fake a named blendTrans filter
135        }
136
137        function fixCoolmenus(name){
138                if(fixed){return;}fixed=true;
139                defineMagicVariable.call=call;
140                // Version 4 is Opera 7 - compatible and does user agent sniffing
141                navRestore['userAgent'] = navigator.userAgent;
142                navigator.userAgent +=' msie 6';
143                shouldRestore = true;
144                defineMagicVariable.call(opera, 'bw', function(o){
145                        // we need to override yet some more browser detection, and disable CSS filters
146                        // usedom must be 0 to make frameset menus work
147                        o.filter=o.op7=o.op=o.usedom=o.ns6=0;
148                        o.ie=o.ie6=1;
149                        return o}, function(o){return o});
150                addPreprocessHandler(  'this.win.document.body.appendChild(oNS)',  'try{this.win.document.body.appendChild(oNS)}catch(e){oNS=this.win.document.body.appendChild(this.win.document.importNode(oNS, true))}' );
151                addPreprocessHandler(  'oNS.appendChild(oNS2)',  'try{oNS.appendChild(oNS2);}catch(e){oNS2=oNS.appendChild(oNS.document.importNode(oNS2, true));}' );
152        }
153
154        function fixHVMenu(name){
155                if(fixed){return;}fixed=true;
156                defineMagicVariable.call=match.call=call;
157                // fix by changing Opera from an unsupported browser to a supported browser
158                // Set to true either PosStrt, NavYes, DomNav   or   PosStrt, ExpYes, DomExp
159                defineMagicVariable.call(opera, 'PosStrt', function(){ return true }, null);
160                defineMagicVariable.call(opera, 'NavYes', function(){ return true }, null);
161                defineMagicVariable.call(opera, 'DomNav', function(){ return true }, null);
162                // if Opera >= 9.5, load events are sent to document and not to body - make sure script doesn't set body.onload
163                defineMagicVariable.call(opera, 'Trigger', function(obj){if(obj===document||obj===document.body) return window; return obj; }, null);
164                // Tell the script that CSS filters are not supported.
165                defineMagicVariable.call(opera, 'Fltr', function(){ return false; }, function(){ return });
166                // More recent versions look for 'opera 7' in navigator.userAgent and some do not use the variable names above
167                if(  match.call(name, /var\.js$/) || match.call(name, /compact\.js$/) ){
168                        navRestore['userAgent'] = navigator.userAgent;
169                        navigator.userAgent+=' opera 7';
170                        shouldRestore = true;
171                }
172        }
173        function fixHierMenus(){
174                if(fixed){return;}fixed=true;
175                defineMagicVariable.call=call;
176              // HM_IsMenu must be true to make the menu appear
177              // HM_BrowserString should be DOM to make the right library load
178                defineMagicVariable.call(opera, 'HM_IsMenu', function(){ return true}, function(){ return true });
179                if(!document.all)defineMagicVariable.call(opera, 'HM_IE', function(){ return true}, function(){ return true });
180                defineMagicVariable.call(opera, 'HM_BrowserString', function(){ return 'DOM'}, function(){ return 'DOM' });
181                if(HTMLBodyElement.prototype.__defineGetter__)HTMLBodyElement.prototype.__defineGetter__('clientHeight', function(){return this.ownerDocument.documentElement.clientHeight;}); // PATCH-33
182        }
183
184function fixLiknoAllWebMenus(ev){
185        indexOf.call=match.call=defineMagicVariable.call=postError.call=removeEventListener.call=appendChild.call=createElement.call=preventDefault.call=replace.call=call;
186        if(fixed)return; fixed=true;
187        if( indexOf.call(ev.element.text, 'AllWebMenus Libraries Version # ' )>-1 ){
188                // AWM loads different libraries based on numbers - number 2 is Gecko-compat
189                // some outdated Opera-libraries are now broken due to bug fixes and such.
190                var awmVersion = parseInt(match.call(ev.element.text, /AllWebMenus Libraries Version # (\d*)/)[1]);
191                if( awmVersion <=531  ){ // likely to old to work..
192                        defineMagicVariable.call(opera,   'scriptNo', function(){return 2}, null);
193                        defineMagicVariable.call(opera,   'awmBefore7', function(){return false}, function(){return false} );
194                        preventDefault.call(ev); // don't run this script
195                        var script = appendChild.call(document.body, createElement.call(document, 'script')); // create another one..
196                        script.src = replace.call(ev.element.src, /awmlib\d*\.js/, 'awmlib2.js'); // and load a more suitable version
197                        postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (AllWebMenus fix). See browser.js for details.');
198                }
199                removeEventListener.call(opera, 'BeforeScript', arguments.callee, false );
200        }
201}
202        function fixMilonicMenu(name){  // gotcha: must be called with script.src as argument
203                if(fixed){return;}fixed=true;
204                defineMagicVariable.call=defineMagicFunction.call=addEventListener.call=call;
205              // "opera" or "opra" true will cause no menu or garbled (Opera 6 pixel* -  compat)
206                defineMagicVariable.call(opera, 'opera', function(){ return false }, function(){});
207                defineMagicVariable.call(opera, 'opra', function(){ return false }, function(){});
208                // ie55 true will use IFRAME shims
209                defineMagicVariable.call(opera, 'ie55', function(){ return false }, function(){ });
210                // identifying as Opera will cause "dom" variable to be false in some versions
211                defineMagicVariable.call(opera,  'dom' , function(){ return true }, function(){});
212                // fixForm function will hide page content
213                defineMagicFunction.call(opera,  'fixForm' , function(){});
214                // Menu does not work on Mac if it detects platform
215                defineMagicVariable.call(opera, 'mac', function(){ return false }, function(){ });
216                // bug 330958
217                if(!window.scrollX){
218                        opera.defineMagicVariable('scrollY', function(){ return document.body.scrollTop;}, null);
219                        opera.defineMagicVariable('scrollX', function(){ return document.body.scrollLeft;}, null);
220                }
221        }
222
223function fixOpenCube(name){// IMPORTANT gotcha: the fixOpenCube and fixHVMenu functions must be called with an appropriate string argument
224        if(fixed)return;
225        match.call=addEventListener.call=defineMagicVariable.call=indexOf.call=call;
226        // OpenCube menu
227        window.vxml = window.vxml||{}; // to fix semi-opera-detection
228        //Some versions try to call a function q99 which is only defined in the Opera library
229        addEventListener.call(window, 'load', function(){ if(typeof q99=='undefined')window.q99=function(){}  }, false);
230        // fake some support for the menu version that tries to use CSS filters in spite of magic var below
231        fakeCSSFilters();
232        // We'll overrule their sniffing and find the correct library for Opera
233        if(indexOf.call(navigator.appVersion, 'Mac')!=-1){
234                // They don't seem to like Macs.. see 356184
235                navigator.appVersion = replace.call( navigator.appVersion, 'Mac', 'M A C' );
236                addEventListener.call(opera, 'AfterExternalScript', function(){
237                        replace.call = removeEventListener.call = call;
238                        navigator.appVersion = replace.call( navigator.appVersion, 'M A C', 'Mac' );
239                        removeEventListener.call(opera, 'AfterExternalScript', arguments.callee, false);
240                }, false);
241                // some variables are uninitialized
242                q20=q21=[];
243        }
244        if(match.call(name, /dqm_script\d*\.js$/)){
245                defineMagicVariable.call(opera, 'brn', function(val){ return 'ie' }, function(val){ return 'ie' });
246                defineMagicVariable.call(opera, 'ie6', function(val){ return true }, function(val){ return true });
247                // prevent the menu from trying to use CSS filters
248                defineMagicVariable.call(opera, 'DQM_sub_menu_effect',  function(){return 'none';}, null);
249                if(document.evaluate){ // we have an event transparency problem on some sites, see for example bug 239622
250                        addEventListener.call(window, 'load', function(){
251                                var nodes=document.evaluate( '//a/child::img[substring(@id, 0, 4)=\'qmim\']', document.body,null,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null ),node;
252                                while( node=nodes.iterateNext()){
253                                        node.parentElement.parentElement.replaceChild(node, node.parentElement );
254                                };
255                        }, false);
256                }
257                fixed=true;
258                return true;
259        }else if(indexOf.call(name, 'dqm_loader.js')>-1){
260                defineMagicVariable.call(opera, 'brn', function(val){ return 'opera7' }, function(val){return 'opera7'});
261                // prevent the menu from trying to use CSS filters
262                defineMagicVariable.call(opera, 'DQM_sub_menu_effect',  function(){return 'none';}, null);
263                fixed=true;
264                return true;
265        }else if(indexOf.call(name, 'dnm_script.js')>-1){ // very old version.. 153257
266                defineMagicVariable.call(opera, 'ie5', function(val){ return true }, function(val){ return true });
267                defineMagicVariable.call(opera, 'ns5', function(val){ return true }, function(val){ return true });
268        }
269}
270
271        function fixSoThinkMenus(){
272                if(fixed){return;}fixed=true;
273                defineMagicVariable.call=addEventListener.call=call;
274                defineMagicVariable.call(opera, 'nOP',function(){return false;},null);
275                defineMagicVariable.call(opera, 'nIE',function(){return false;},null);
276                defineMagicVariable.call(opera, 'nNN6',function(){return true;},null);
277                addEventListener.call(window, 'load', function(e){ if(window.st_onload)st_onload(e); }, false );//PATCH-55
278        }
279
280        function fixTransmenus(){
281                // Fixing bugs in menu script from http://www.youngpup.net/2004/transmenus/
282                // Credits xErath and Andrew Gregory
283                opera.addEventListener('BeforeScript', function(ev) {
284                        indexOf.call=replace.call=removeEventListener.call=call;
285                        var js = ev.element.text;
286                        if (indexOf.call(js, "TransMenu")!=-1) {
287                                js = replace.call(js, /return\s+r(\b)/,"return true$1");
288                                js = replace.call(js, /mac/g,"xpto");
289                                js = replace.call(js, "el.scrollLeft", "0");
290                                js = replace.call(js, "el.scrollTop", "0");
291                                ev.element.text = js;
292                                removeEventListener.call(opera, 'BeforeScript', arguments.callee, false);
293                        }
294                }, false);
295        }
296
297        function fixUDM(name){
298                if(fixed){return;}fixed=true;
299                defineMagicVariable.call=call;
300                // If the menu is a 3.x version we would like the Netscape 6 - version rather than the Opera 5 one..
301                defineMagicVariable.call(opera, 'op5',function () { return 0; },null);
302                defineMagicVariable.call(opera, 'ns6',function () { return 1; },null);
303
304                // certain versions break if insertRule throws exceptions. Also see bug 242411.
305                // Better fake missing support for DOM2Style then..
306                defineMagicVariable.call(opera, 'um', function(o){ o.ss=false; o.o7=false; return o; }, null);
307    }
308
309function sendOperaEvent(name, target){
310        initEvent.call=createEvent.call=dispatchEvent.call=call;
311        var evt=createEvent.call(document, 'Event');
312        initEvent.call(evt, name, false, false);
313        evt.element=target;
314        dispatchEvent.call(opera, evt);
315}
316function setTinyMCEVersion(e){
317        if(tinyMCEVersionInfo.majorVersion)return; // already found it
318        indexOf.call=match.call=call;
319        // look at source code
320        if( e && indexOf.call(e.element.text, 'majorVersion' )>-1  ){
321                if(match.call(e.element.text, /majorVersion\s*[:=]+\s*["']?(\d)/)){ tinyMCEVersionInfo.majorVersion=RegExp.$1; }
322                if(match.call(e.element.text, /minorVersion\s*[:=]+\s*["']?(\d(\.\d|))/)){ tinyMCEVersionInfo.minorVersion=RegExp.$1; }
323        }
324        // if an instance has already been created, we can read version info from it...
325        var tinyInstance='tinyMCE' in window?window.tinyMCE : 'tinymce' in window ? window.tinymce : 'tiny_mce' in window ?  window.tiny_mce : null;
326        if(tinyInstance&&tinyInstance.majorVersion)tinyMCEVersionInfo={ majorVersion:tinyInstance.majorVersion, minorVersion:tinyInstance.minorVersion };
327}
328
329
330
331
332
333        // Generic JS library patches
334// Hide broken implementation of showModalDialog to make object detection reliable
335// Remove non-functional addEventListener from XHR objects
336// Disable sniffing in old HTMLArea editors
337// Asia-region Generic Patches
338// Disable HTMLElement.removeNode support, compat experiment
339                        // 0, Generic JS library patches
340        // Use an event listener to detect specific scripts
341        opera.addEventListener( 'BeforeExternalScript', function(ev){
342                match.call=replace.call=indexOf.call=toLowerCase.call=postError.call=addEventListener.call=removeEventListener.call=version.call=parseFloat.call=call;
343               
344                var name=ev.element.src;
345                if( !name ){ return; } // no fixes required for SCRIPT xlink:href so far..
346                name=toLowerCase.call(name );// toLowerCase fixes sangjatten.se
347              if ( indexOf.call(name, 'dqm_')>-1 || indexOf.call(name, 'dnm_')>-1 || indexOf.call(name, 'cbrowser_opera.js')>-1 ){
348                        // OpenCube menu
349                        if(fixOpenCube(name)){
350                                postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (OpenCube fix). See browser.js for details.');
351                        }
352                        return;
353              }else if(  indexOf.call(name, 'hm_loader')>-1  ){
354                        // HierMenus menu
355                        // If we apply this fix to version 6.x the menu breaks.
356                        // HM support recommends checking that HM_BrowserVersion is not defined
357                        addEventListener.call(opera, 'BeforeScript', function(ev){
358                                match.call=removeEventListener.call=postError.call=call;
359                                if( ev.element.text && ! match.call(ev.element.text, /hm_browserversion/i) ){
360                                        fixHierMenus(name);
361                                        postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (HierMenus fix). See browser.js for details.');
362                                }
363                                removeEventListener.call(opera, 'BeforeScript', arguments.callee, false);
364                        }, false);
365                        return;
366              }else if(  indexOf.call(name, 'mmenu')>-1 || indexOf.call(name, 'milonic')>-1  ){
367                        // Milonic menu
368                        fixMilonicMenu(name);
369                        postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Milonic fix). See browser.js for details.');
370                        return;
371               
372              }else if(  match.call(name, /menu(\d*_(script|com|build|var|program|compact)|e)\.js$/)  ){
373                        // HV menu
374                        fixHVMenu(name);
375                        postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (HVMenu fix). See browser.js for details.');
376                        return;
377              }else if(  match.call(name, /coolmenus\d?.js$/)   ){
378                        // coolmenus menu
379                        fixCoolmenus(name);
380                        postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Coolmenus fix). See browser.js for details.');
381                        return;
382              }else if(  match.call(name, /udm[_-]/)  || (  match.call(name, /(sniffer|control)\.js$/)   )    ){
383                        // UDM menu
384                        addEventListener.call(opera, 'BeforeScript', function(ev){
385                                match.call=postError.call=call;
386                                if( match.call(name, /udm[_-]/)  || indexOf.call(ev.element.text, 'UDM')>-1 || indexOf.call(ev.element.text, 'um.ov=um.ov.split(/opera[\\/ ]7./);um.ov=um.pi(um.ov[1].charAt(0));')>-1 ){
387                                        fixUDM(name);
388                                        postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (UDM fix). See browser.js for details.');
389                                }
390                        }, false);
391                        return;
392              }else if(  indexOf.call(name, 'dynapi/api/browser.js')>-1  || indexOf.call(name, 'dynlayer.js')>-1  ){
393                        navRestore['appName'] = navigator.appName;
394                        navigator.appName = 'Microsoft Internet Explorer';
395                        shouldRestore = true;
396                        postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (DynAPI fix). See browser.js for details.');
397                }else if(  match.call(name, /stm(\d+|_menu).js$/)  ){
398                        fixSoThinkMenus();
399                        postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (SoThink fix). See browser.js for details.');
400                }else if( indexOf.call(name, 'transmenu')>-1 ){
401                        fixTransmenus();
402                        postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Transmenu fix). See browser.js for details.');
403                }else if( indexOf.call(name, 'xaramenu')>-1 ){
404                        addPreprocessHandler( new RegExp('if\\(navigator.userAgent.indexOf\\(\'Opera\'\\)!=-1\\)\\s*NS4=1;', ''), 'if(navigator.userAgent.indexOf(\'Opera\')!=-1){IE5=1;NS6=0;}');
405                        postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Xaramenu fix). See browser.js for details.');
406                }else if( parseFloat.call(window, version.call())<9.5 && indexOf.call(name, '/novell/webaccess/images/msglist.js')>-1){ // Bug 92454, workaround for NWA
407                        defineMagicFunction.call(opera, 'fixContentHeight',
408                                function(oF, oT){
409                                        document.documentElement.clientHeight=window.innerHeight;
410                                        oF.apply(oT, slice.call(arguments, 2));
411                        });
412                        postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Height function fix). See browser.js for details');
413                }else if( indexOf.call(name, 'awmlib')>-1 ){
414                                opera.addEventListener('BeforeScript', fixLiknoAllWebMenus, false);
415                }else if( indexOf.call( name, 'tiny_mce' )>-1 && 'designMode' in document && !fixed){
416                                postError.call(opera, 'TinyMCE detected. Various fixes applied. See browser.js for details');
417                                addEventListener.call(opera, 'BeforeScript', function(e){
418                                        indexOf.call=removeEventListener.call=call;
419                                        if( indexOf.call(e.element.src, 'tiny_mce'>-1) ){
420                                                setTinyMCEVersion(e);
421                                                sendOperaEvent( 'bjsOnTinyMCEScript', e.element );
422                                        }
423                                }, false);
424                                addEventListener.call(opera, 'BeforeEvent.load', function(e){
425                                        match.call=call;
426                                        if( match.call(e.event.target.tagName, /iframe/i) && ( match.call(e.event.target.name, /^mce_editor_\d/ ) || match.call(e.event.target.id, /^mce_editor_\d/ ))){
427                                                setTinyMCEVersion();
428                                                sendOperaEvent('bjsOnTinyMCEInstance', e.event.target);
429                                        }
430                                }, false);
431                                fixed=true;
432                }else if(indexOf.call(name, 'dev.virtualearth.net/mapcontrol/mapcontrol.ashx')>-1 && window.SVGDocument){
433                        navRestore.userAgent = navigator.userAgent;
434                        navigator.userAgent+='KHTML';//356736
435                        shouldRestore=true;
436                }else if(indexOf.call(name,'s_code')>-1||indexOf.call(name,'omniture')>-1){//PATCH-59
437                        avoidDocumentWriteAbuse();
438                }else if(indexOf.call(name,'setdomain.js')>-1){//PATCH-128
439                        navRestore.userAgent = navigator.userAgent;
440                        navigator.userAgent+=' Gecko';
441                        shouldRestore=true;
442                }else if(indexOf.call(name,'connect.facebook.net')>-1 && indexOf.call(name,'all.js')>-1){
443                                var win_attachEvent=window.attachEvent;
444                                if( window.fbAsyncInit ){
445                                        var origFBAsyncInit=window.fbAsyncInit;
446                                        window.fbAsyncInit=function(){
447                                                window.attachEvent=undefined;
448                                                origFBAsyncInit.call(null);
449                                                window.attachEvent=win_attachEvent;
450                                        }
451                                }else{
452                                        window.attachEvent=undefined;
453                                        addEventListener.call(opera, 'AfterScript', function(e){
454                                                window.attachEvent=win_attachEvent;
455                                                removeEventListener.call(opera, 'AfterScript', arguments.callee, false);
456                                        }, false);
457                                }
458                        }
459                if( typeof window._jive_plain_quote_text!='undefined' ){ // Jive forum embeds TinyMCE, possibly outdated versions - PATCH-248
460                        opera.addEventListener('BeforeScript', function(e){
461                                indexOf.call=removeEventListener=call;
462                                if(indexOf.call(e.element.text, 'tinymce=')>-1){
463                                        setTinyMCEVersion(e);
464                                        sendOperaEvent( 'bjsOnTinyMCEScript', e.element );
465                                        removeEventListener.call(opera, 'BeforeScript',arguments.callee,false);
466                                }
467                        }, false);
468                }
469                // Creating event handler to restore any changed navigator properties
470                if( shouldRestore ){
471                        addEventListener.call(opera, 'AfterExternalScript',
472                                function(ev){
473                                        removeEventListener.call=call;
474                                        var prop;
475                                        for(prop in navRestore) navigator[prop]=navRestore[prop];
476                                        removeEventListener.call(opera, 'AfterExternalScript', arguments.callee, false);
477                                }
478                        , false);
479                }
480        }, false);
481                        // PATCH-261, Hide broken implementation of showModalDialog to make object detection reliable
482        delete showModalDialog;
483                        // PATCH-272, Remove non-functional addEventListener from XHR objects
484        delete XMLHttpRequest.prototype.addEventListener;
485                        // PATCH-298, Disable sniffing in old HTMLArea editors
486        opera.defineMagicVariable('HTMLArea', null, function(obj){
487                obj.__defineGetter__('is_gecko', function(){return true});
488                obj.__defineSetter__('is_gecko', function(){});
489                obj.__defineGetter__('checkSupportedBrowser', function(){return function(){return true;}});
490                obj.__defineSetter__('checkSupportedBrowser', function(){});
491                var onloadmethod;
492                obj.__defineSetter__('onload', function(func){ onloadmethod=func;});
493                obj.__defineGetter__('onload', function(){ return function(){ try{ onloadmethod.call(this);}catch(e){ var instance=this; setTimeout(function(){instance.onload();}, 150); }}});
494                opera.postError('Opera has modified the JavaScript on '+hostname+' (HTMLArea fix). See browser.js for details');
495                return obj;
496        });
497       
498                        // 0, Asia-region Generic Patches
499        opera.addEventListener('BeforeExternalScript',function(ev){
500                var name=ev.element.src;
501                if(!name){return;}
502                if(name.indexOf('api.e-map.ne.jp/jsapi.cgi?')!=-1){
503                        // Zenrin Datacom E-Map API, PATCH-115
504                        if (!Event.prototype.__lookupGetter__('layerX')&&!Event.prototype.__lookupGetter__('layerY')) {
505                                Event.prototype.__defineGetter__('layerX',function(){ return this.offsetX; });
506                                Event.prototype.__defineGetter__('layerY',function(){ return this.offsetY; });
507                        }
508                        ev.element.src += '&force=1';
509                }else if((name.indexOf('expapi/authentication')!=-1)||(name.indexOf('expapi/expmapinclude')!=-1)||(name.indexOf('rosen/authentication')!=-1)){
510                        // Rosenzu ASP Map Service map, PATCH-122
511                        opera.defineMagicFunction('_ch',function(){return true;});
512                }else if((name.indexOf('expapi/suggest')!=-1)||(name.indexOf('rosen/suggest')!=-1)){
513                        // Rosenzu ASP Map Service suggestions, PATCH-122
514                        opera.defineMagicFunction('checkBrowser',function(){return true;});
515                }else if(name.indexOf('http://ebook.webcatalog.jp/engine/java/7net/common/sCommonLib.js')!=-1){
516                        // Netfly TrueEBook, PATCH-125
517                        opera.defineMagicFunction('funcGetBrowser',function(){return 2;});
518                }
519        },false);
520                        // PATCH-331, Disable HTMLElement.removeNode support, compat experiment
521        delete HTMLElement.prototype.removeNode;
522
523
524        if(hostname.indexOf('.ebay.')>-1 || hostname.indexOf('.ebaydesc.')>-1){                 // 0, eBay
525                /* eBay issues */
526       
527       
528                // Avoid IFRAME resize causing lots of empty space on auctions
529                                // PATCH-195, Avoid IFRAME resize causing lots of empty space on auctions
530                function resizeIframesAndPassSizeOn(e){
531                        if(e && e.type==='message' && e.origin.indexOf('ebaydesc')>-1){
532                                for(var iframes=document.getElementsByTagName('iframe'),iframe,i=0;iframe=iframes[i];i++){
533                                        if(iframe.src.indexOf(e.origin)>-1){
534                                                iframe.style.height=(20+parseInt(e.data))+'px';
535                                        }
536                                }
537                        }
538                        if(top!=self)parent.postMessage(document.documentElement.scrollHeight, '*');
539                }
540                window.addEventListener('message', resizeIframesAndPassSizeOn, false);
541               
542       
543       
544                if(hostname.indexOf('.ebaydesc.')>-1){                  // PATCH-195, Avoid IFRAME resize causing lots of empty space on auctions (the IFRAME part)
545                        window.addEventListener('load', function(){
546                                setTimeout(function(){
547                                        if(top!=self)parent.postMessage(document.documentElement.scrollHeight, '*');
548                                }, 100);
549                        }, false);
550                        setTimeout(function(){
551                                if(top!=self)parent.postMessage(document.documentElement.scrollHeight, '*');
552                        }, 600);
553                       
554                                if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Avoid IFRAME resize causing lots of empty space on auctions (the IFRAME part)). See browser.js for details');
555                }
556                        if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (eBay). See browser.js for details');
557        } else if(hostname.indexOf('.google.')>-1){                     // 0, Google
558                /* Google */
559       
560       
561                if(hostname.indexOf('.com.tw')>-1 || hostname.indexOf('.co.jp')>-1 || hostname.indexOf('.com.hk')>-1){                  //  PATCH-342, Google script that blurs and re-focuses input field prevents spatial navigation
562                        HTMLInputElement.prototype.blur=HTMLInputElement.prototype.focus=function(){};
563                       
564                                if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Google script that blurs and re-focuses input field prevents spatial navigation). See browser.js for details');
565                }
566                if(hostname.indexOf('code.google.')>-1 && (pathname.indexOf('diff')>-1 || pathname.indexOf('detail')>-1 )){                     // PATCH-321, Work around pre inheritance into tables on Google Code
567                        addCssToDocument('div.diff>pre>table{white-space: normal;}div.diff>pre>table th, div.diff>pre>table td{white-space: pre-wrap;}');
568                                if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Work around pre inheritance into tables on Google Code). See browser.js for details');
569                }
570                        if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Google). See browser.js for details');
571        } else if(hostname.indexOf('.in.gr')>-1){                       // PATCH-367, Correct placement of marquee on in.gr
572                document.addEventListener('DOMContentLoaded', function(){
573                 elm = document.getElementById('ticker-area');
574                 if(elm){
575                  elm.innerHTML=elm.innerHTML.replace(/&nbsp;/,'');
576                 }
577                },false);
578                        if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Correct placement of marquee on in.gr). See browser.js for details');
579        } else if(hostname.indexOf('.jcrew.com')>-1){                   // PATCH-338, If XHR doesn't support EventTarget interface, setting onload should throw
580                XMLHttpRequest.prototype.__defineSetter__('onload', function(){ throw 'unsupported'; });
581                        if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (If XHR doesn\'t support EventTarget interface, setting onload should throw). See browser.js for details');
582        } else if(hostname.indexOf('.yahoo.')>-1){                      // 0, Yahoo!
583                /* Yahoo! */
584       
585       
586                if(hostname.indexOf('.mail.yahoo.')>-1&&(href.indexOf( '/dc/system_requirements?browser=blocked' )>-1||href.indexOf( '/dc/system_requirements?browser=unsupported' )>-1)){                      // 194334, Y!Mail work around browser blocking
587                        location.href='/dc/launch?sysreq=ignore';
588                       
589                                if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Y!Mail work around browser blocking). See browser.js for details');
590                }
591                if(hostname.indexOf('.mail.yahoo.')>=0 && pathname.indexOf('/dc/')==0){                 // CORE-17538, Y!Mail avoid text selection on drag-and-drop
592                        window.addEventListener('mousedown', function(evt) {
593                                var target = evt.target;
594                                var cursor = getComputedStyle(target, null).cursor;
595                                if (/move/i.test(cursor) || /size/i.test(cursor)) {
596                                        evt.preventDefault();
597                                } else if (!('value' in target) /* don't preventDefault for <input>, etc */) {
598                                        for (var node = target; node; node = node.parentNode) {
599                                                if (node.hasAttribute && node.hasAttribute('tabindex')) {
600                                                        evt.preventDefault();
601                                                        break;
602                                                }
603                                        }
604                                }
605                        }, true);
606                                        // 321384, createElement in XML document should put un-prefixed nodes in null namespace
607                        var docCreateElement = Document.prototype.createElement;
608                        if( window.XMLDocument ){
609                                XMLDocument.prototype.createElement = function(n){ return n.indexOf(':')==-1 ? this.createElementNS(null, n) : docCreateElement.call(this,n); }
610                        }else{
611                                Document.prototype.createElement = function(n){ return n.indexOf(':')==-1 ? this.createElementNS(null, n) : docCreateElement.call(this,n); }
612                        }
613                                        // 194334, Y!Mail preventing drag from selecting text
614                        if( self==top )
615                                opera.addEventListener('BeforeEventListener.mousedown',function(e){
616                                                try{
617                                                        indexOf.call = preventDefault.call = call;
618                                                        if( indexOf.call(e.event.target.parentNode.parentNode.className, 'messageRow')>-1)
619                                                                preventDefault.call(e.event);
620                                                }catch(e){}
621                                },false);
622                       
623                        document.addEventListener('mousemove',function(e){
624                                if( e.target.getAttribute('unselectable')=='on' )
625                                        e.target.ownerDocument.defaultView.getSelection().removeAllRanges();
626                        },false);
627                       
628                                        // 194334, Y!Mail remove selectSingleNode and selectNodes
629                        /* because Yahoo mail is better at emulating proprietary IE functions than we are.. */
630                        Node.prototype.selectSingleNode=undefined;
631                        Node.prototype.selectNodes=undefined;
632                                if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Y!Mail avoid text selection on drag-and-drop\ncreateElement in XML document should put un-prefixed n...). See browser.js for details');
633                }
634                if(hostname.indexOf('mail')==-1){                       // 271238, Yahoo ISP portal blocks Opera users
635                        addPreprocessHandler( /d\.location\.href = ".*?\/browser_upgrade\.html";/g, '');
636                                if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Yahoo ISP portal blocks Opera users). See browser.js for details');
637                }
638                        if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Yahoo!). See browser.js for details');
639        } else if(hostname.indexOf('blogger.com')>-1){                  // DSK-152851, Blogger: browser detection prevents WYSIWYG editing
640                navigator.product = 'Gecko';
641                navigator.userAgent = navigator.userAgent.replace(/Opera/, 'Firefox')+' ( rv:1.9.0.3)';
642               
643                opera.defineMagicVariable(
644                        'Detect',
645                        function( obj ){return obj;},
646                        function( obj ){
647                                obj.OPERA = function(){return false;}
648                                obj.MOZILLA = function(){return true;}
649                                obj.IE=function(){return false;}
650                                obj.IE_5_5_newer=function(){return false;}
651                                return obj;
652                        }
653                );
654               
655                                // PATCH-206, Don't override native click() method and expect to submit forms by calling click() on a button..
656                HTMLInputElement.prototype.click=HTMLButtonElement.prototype.click=HTMLElement.prototype.click;
657                        if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Blogger: browser detection prevents WYSIWYG editing\nDon\'t override native click() method and expect...). See browser.js for details');
658        } else if(hostname.indexOf('cambrian.mb.ca')>-1){                       // PATCH-285, Enable log-in button on Cambrian bank
659                Element.prototype.__defineGetter__('all', function(){});
660                        if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Enable log-in button on Cambrian bank). See browser.js for details');
661        } else if(hostname.indexOf('computerra.ru')>-1){                        // PATCH-267, Make BBCode editor buttons work by disabling Opera sniffing
662                document.addEventListener('DOMContentLoaded', function(){
663                        if(window.jsUtils&&window.jsUtils.bOpera)jsUtils.bOpera=false;
664                }, false);
665                        if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Make BBCode editor buttons work by disabling Opera sniffing). See browser.js for details');
666        } else if(hostname.indexOf('espn.go.com')>-1){                  // PATCH-375, Make sure the ESPN polls work
667                navigator.appName="netscape";
668                        if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Make sure the ESPN polls work). See browser.js for details');
669        } else if(hostname.indexOf('footballteam.pl')>-1){                      // PATCH-358, Enable the password box on footballteam.pl
670                HTMLInputElement.prototype.__defineSetter__('type',function(){
671                        if (this.getAttribute('type')!=arguments[0]) {
672                                var doFocus=false, result;
673                                if (this == document.activeElement) doFocus = true;
674                                result = this.setAttribute('type',arguments[0]);
675                                if (doFocus) this.focus();
676                                return result;
677                        }
678                });
679               
680                        if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Enable the password box on footballteam.pl). See browser.js for details');
681        } else if(hostname.indexOf('geoaccess.com')!=-1){                       // 318050,  BlueCross browser sniffing prevents insurance search
682                opera.defineMagicVariable('is_nav', function(){return true;}, null);
683               
684                        if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' ( BlueCross browser sniffing prevents insurance search). See browser.js for details');
685        } else if(hostname.indexOf('kort.arealinfo.dk')>-1){                    // PATCH-348, Disable Opera detection that causes hidden content
686                opera.defineMagicVariable('op', function(){return false}, null);
687                        if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Disable Opera detection that causes hidden content). See browser.js for details');
688        } else if(hostname.indexOf('mail.live.com')!=-1){                       // CORE-17497, Opera doesn't support col-resize/row-resize cursors.
689                addCssToDocument('html .SplitterBarH { cursor: s-resize } html .SplitterBarV { cursor: e-resize } #masterSplitter { cursor: e-resize }');
690                                // DSK-235885, Hotmail uses lookupGetter on prototypes, not instances
691                var styleSetterLookupMethod = document.createElement('span').style.__lookupSetter__;
692                 CSSStyleDeclaration.prototype.__lookupSetter__ = function(prop){
693                        return styleSetterLookupMethod.call(document.createElement('span').style, prop);
694                 };
695                                // PATCH-135, Fixes removing contacts from To field by clicking small X icon
696                addCssToDocument('.ContactPicker_AutoComplete img{position:static!important;}');
697                        if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Opera doesn\'t support col-resize/row-resize cursors.\nHotmail uses lookupGetter on prototypes, not i...). See browser.js for details');
698        } else if(hostname.indexOf('meebo.com')>-1){                    // OTW-6247, Meebo tries to use detachEvent to remove listeners added with addEventListener due to inversed feature detection in their ui.detachEvent method
699                delete window.detachEvent;
700                delete Node.prototype.detachEvent;
701                        if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Meebo tries to use detachEvent to remove listeners added with addEventListener due to inversed featu...). See browser.js for details');
702        } else if(hostname.indexOf('myspace.com')>-1){                  // PATCH-266, Opera disallows using reserved word top as variable name
703                (function(){
704                        var the_top;
705                        opera.defineMagicVariable('top', function(){return the_top;}, function(o){the_top=o;});
706                })();
707               
708                        if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Opera disallows using reserved word top as variable name). See browser.js for details');
709        } else if(hostname.indexOf('news.qq.com')>-1){                  // PATCH-112, weather.news.qq.com uses document.all for browser detection
710                opera.defineMagicVariable('ie4',function(){return true;}, null);
711                        if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (weather.news.qq.com uses document.all for browser detection). See browser.js for details');
712        } else if(hostname.indexOf('opera.com')>-1&& pathname.indexOf('/docs/browserjs/')==0){                  // 0, Browser.js status and version reported on browser.js documentation page
713                document.addEventListener((parseFloat(opera.version())>9?'DOMContentLoaded':'load'),function(){
714                        if(document.getElementById('browserjs_active')){
715                                document.getElementById('browserjs_active').style.display='';
716                                document.getElementById('browserjs_active').getElementsByTagName('span')[0].appendChild(document.createTextNode(bjsversion));
717                                document.getElementById('browserjs_status_message').style.display='none';
718                        }else if(document.getElementById('browserjs_status_message')){
719                                document.getElementById('browserjs_status_message').firstChild.data='Browser.js is enabled! '+bjsversion;
720                        }
721                }, false);
722                        if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Browser.js status and version reported on browser.js documentation page). See browser.js for details');
723        } else if(hostname.indexOf('tvguide.com')>-1){                  // PATCH-274, TVGuide doesn't show program descriptions, due to browser sniffing
724                opera.defineMagicVariable('isSafari', function(){return true;}, null);
725                        if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (TVGuide doesn\'t show program descriptions, due to browser sniffing). See browser.js for details');
726        } else if(hostname.indexOf('westjet.com')>-1 ){                 // PATCH-260,  Westjet browser sniffing warns against Opera
727                opera.defineMagicVariable('browser', function(o){ o.isSupported=true; return o; }, null);
728                        if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' ( Westjet browser sniffing warns against Opera). See browser.js for details');
729        } else if(hostname.indexOf('www.yoka.com')>-1){                 // PATCH-238, Override minmax IE helper script
730                opera.defineMagicFunction('minmax_scan', function(){});
731                        if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Override minmax IE helper script). See browser.js for details');
732        } else if(href.indexOf('/sample_lr.html')>-1){                  // PATCH-128, Sun Webmail fails to set document.domain due to browser sniffing
733                navigator.userAgent+=' Gecko';
734                        if(self==top)postError.call(opera, 'Opera has modified the JavaScript on '+hostname+' (Sun Webmail fails to set document.domain due to browser sniffing). See browser.js for details');
735        }
736
737})(opera);
Note: See TracBrowser for help on using the repository browser.