Skip navigation.

Prepare!

Lee Harvey's Zombie Hit Parade

Posts tagged with "browser"

UserJS fix for ASUS Product Comparison page

, , , ...

The ASUS Product Comparison page seems to contain JavaScript code written specifically for MSIE or FF (untested). In any event, the page does not work correctly in Opera, mostly due to their calls to new ActiveXObject.

Below, I've taken the liberty of correcting their processRequest and add JavaScript functions found in this external load_data.js script.

Click here to download/view the asus.js script

if (document.domain.match(/(uk\.)?asus\.com$/)) {

   window.opera.defineMagicFunction("processRequest",
      function(a, b, c) {
         if (http_request.readyState != 4) return;
         if (http_request.status != 200) return;

         var dpl1=document.getElementById("dpl_l1");
         var dpl2=document.getElementById("dpl_l2");
         var dpl3=document.getElementById("dpl_l3");
         var dpl4=document.getElementById("dpl_l4");
         var lbl=document.getElementById("lbl_model");
        
         var parser = new DOMParser();
         var xmldoc = parser.parseFromString(http_request.responseText,"text/xml");
         var dataArray = xmldoc.getElementsByTagName('Table1');
         var dataArrayLen = dataArray.length;
         for (var i=0; i<dataArrayLen; i++)
         {
            var get_id=dataArray[i].getElementsByTagName("id_name")[0].text;
            var get_value=dataArray[i].getElementsByTagName("id_value")[0].text;
            var opt = new Option(get_value, get_id, 0, 0);
            if (l1!=0&&list_model==2) //load level 2
            {
               dpl2.disabled=false;
               dpl2.add(opt);
            }
            else if(l2!=0&&list_model==3) //load level 3
            {
               dpl3.disabled=false;
               dpl3.add(opt);
            }
            else if(l3!=0&&list_model==4) //load level 4
            {
               dpl4.disabled=false;
               dpl4.add(opt);
            }
            else if (list_model==5) 
            {
               dpl3.disabled=(dpl3.length==1);
               lbl.add(opt);
            }
         }
      }, 0);


   window.opera.defineMagicFunction("add", 
      function(a, b, c) {
         var lbl=document.getElementById("lbl_model");
         var lbl_select=document.getElementById("lbl_model_select");
         for(var i=0;i<lbl.options.length;i++)
         {
            if (!lbl.options[i].selected) continue;

            for(var j=0;j<lbl_select.options.length;j++)
               if (lbl.options[i].value==lbl_select.options[j].value)
                  return;

            lbl_select.add(new Option(lbl.options[i].text, lbl.options[i].value));
         }
      }, 0);

}

For those of you who might use this ASUS product comparison page, enjoy.

Remove high CPU caused by Omniture tracking

, , , ...

Opera users that frequent Symantec.com may notice certain pages triggering an extremely high CPU usage for a short burst of time. For example:

http://www.symantec.com/avcenter/threatcon/

A quick analysis of this CPU issue indicates that one JavaScript file is causing this mess:

http://www.symantec.com/content/en/us/omniture/20070301b/OmniScript.js

...most likely due to its inefficient use of deeply nested loops.

As a temporary work-around, you can simply block this script in Opera using the following pattern in the Block content dialog:

http://*.symantec.com/content/*/omniture/*/OmniScript.js

Reloading the example page above shows the high CPU is now gone -- and virtually no page functionality has been lost by blocking this external JavaScript.

Enjoy.

UserJS for Belastingdienst.nl

, , , ...

Most Opera users experience display issues when accessing the following sites:


So, I've written this simple UserJS script to properly apply the correct stylesheet after the page has loaded:

Download/view the belastingdienst.js script:
if (document.domain.match(/^(www\.)?toeslagen\.nl$/) ||
    document.domain.match(/^(www\.)?douane\.nl$/) ||
    document.domain.match(/^(www\.)?belastingdienst\.nl$/)) {

    document.addEventListener("load",
        function() {
            if (SwitchStyleSheet) SwitchStyleSheet("Standaard");
    }, 0);
}

Enjoy.

Enhance Opera's mouse cursor over text

, , , ...

Ever wish Opera's mouse cursor behaved like Firefox's or MSIE's in web pages? You know, when you hover over text in a web page, the cursor actually changes to a meaningful text caret, rather than remaining a stupid old default NW mouse cursor.

Usability experts say that text carets (vertical mouse cursor) should be used as a visual feedback mechanism when underlying text can be selected. Plus, text carets do not obscure underlying text, like the default NW mouse cursor does. Personally, this is just one Opera pet peeve solved with User JavaScript.

So, with my latest UserJS script (shown below), now you too can have this 'smart' mouse cursor feature in Opera!

Keep in mind, this script is currently non-optimized for extremely large pages, or pages with poorly written HTML markup and/or scripts. Regardless, it does seem to work pretty well on most sites.

Download/view the textNodes.js script
document.addEventListener("load",
   function() {

      var body = document.getElementsByTagName("BODY");
      if (!body) return;

      var isIgnored = function(node) {
         var bad = /^(SCRIPT)|(STYLE)|(OPTION)|(TEXTAREA)|(INPUT)|(\#cdata\-section)|(\#comment)$/i;
         var result = false;
         while (node && !result) {
            result = (node.nodeName.match(bad) || 
                     ((node.nodeName == "A") && node.href));
            node = node.parentNode;
         }
         return result;
      }

      var nodeIterator = document.createNodeIterator( 
         body[0], 
         NodeFilter.SHOW_TEXT, 
         { acceptNode : function (node) {
            return (/\S+/.test(node.data) && !isIgnored(node)) ?
               NodeFilter.FILTER_ACCEPT:
               NodeFilter.FILTER_REJECT;
           }
         }, 
         true
      );

      var a = new Array();
      var textNode;
      while ((textNode = nodeIterator.nextNode())) { 
         if (!textNode.parentNode.style) continue;
         if (textNode.parentNode.style.cursor != "") continue;
         if (textNode.parentNode.currentStyle.cursor != "default") continue;
         a.push(textNode);
      }

      if (!a.length) return;
      var ss = false;
      var sheet = null;
      for (var i = 0; i < document.styleSheets.length; i++) {
         sheet = document.styleSheets[i];
         ss = (!sheet.media || !sheet.media.length);
         if (ss) break;
         for (var j = 0, m; m = sheet.media[j]; j++) {
            ss = (m.match(/^(\*)|(all)|(screen)$/i));
            if (ss) break;
         }
      }

      if (ss) sheet.insertRule(
         "SPAN.crsrTxt { \
         font: inherit !important; \
         color: inherit !important; \
         background: none !important; \
         padding: 0 0 0 0 !important; \
         margin: 0 0 0 0 !important; \
         clear: none !important; \
         z-index: inherit !important; \
         float: none !important; \
         display: inline !important; \
         cursor: text !important; }", 0);

      while ((textNode = a.pop())) {
         var span = document.createElement("span");
         if (ss)   span.className = "crsrTxt";
         else {
            span.style.color = "inherit";
            span.style.background = "none";
            span.style.padding = "0 0 0 0";
            span.style.margin = "0 0 0 0";
            span.style.clear = "none";
            span.style.zIndex = "inherit";
            span.style.float = "none";
            span.style.display = "inline";
            span.style.cursor = "text";
         }
         textNode.parentNode.insertBefore(span, textNode);
         span.appendChild(textNode);
      }
   }, 0);

I'll keep this blog entry updated to reflect the most recent version of the script, so stay tuned.

Known issue:
  • Script may not work on poorly coded HTML and JavaScript websites (foxnews.com)
  • There's a known crash bug in Opera 9.20 when using this script on newegg.com

BTW, feedback is always appreciated.

Enjoy.

UserJS fix for Yahoo!'s global search box stealing keystrokes

, , , ...

If you're a regular reader of this blog, then you realize how much I despise Yahoo! web developers. Their latest trick is to steal ALL keyboard input using a setTimeout event poller, then place the keystrokes into their stupid global search edit box at the top of the page. Nice going losers.

Anyhow, if you use Yahoo! Sports, and use ANY keyboard commands in Opera, then I highly recommend downloading this script.

Download/view the yahooSport.js script:
if (document.domain.match(/sports\.yahoo\.com$/)) {
  document.addEventListener("load",
    function() {
      document.sf1 = null;
    }, 0);
}

Enjoy.

UserJS to fix printing TitanTV.com schedules

, , , ...

Mason C reported in the opera.general newsgroup on Jan 30, 2007 that TitanTV.com schedules could not be printed in Opera. After reviewing his claim, I confirmed it and wrote this UserJS script to work-around the problem:

Download/view the titantv.js script
if (document.domain.match(/^(www\.)?titantv\.com$/)) {
   document.addEventListener("load",
      function(e) {
         var inps = document.getElementsByTagName("input");
         for (var i = 0, o; o = inps[i]; i++) {
            if (o.type != "image") continue;
            if (o.getAttribute("alternate") != "Print") continue;
            o.onclick = "window.open(document.forms.Form1.__PrintUrl.value,'','');";
            break;
         }
      }, 0);
}

NOTE: Once the script is installed, reload the page, then click the blue [Print] button that appears on the upper-right corner of their TV schedule pages. Clicking [Print] will open a new pop-up window with a printer-friendly version of the page -- so be sure your Opera pop-up blocker is not set to "Block All". And as always with UserJS scripts, be sure JavaScript is enabled, and that you place the .js file in the correct UserJS folder.

For those of you who use TitanTV.com (very nice, btw, compared to TVGuide.com), and prefer to print-out hard-copies of their TV schedules...enjoy.

My IE7 impressions

, ,

So I took the plunge on one of my Windows PCs and decided to install the now "High priority update" recommended by Microsoft: namely, Internet Explorer 7.0 (IE7).

To borrow an expression from my kids:

What a piece of junk!


While I applaud Microsoft's attempt to offer a browser that approaches modern-day standards, I was totally turned-off by the lack of configuration options, and its slow page loading and rendering speed.

Seriously, who in their right mind at Microsoft thought it was a good idea to not allow the menu bar above the main navigation toolbar? I mean, every single Microsoft product (besides IE7) that I know of, adhere's to this general Windows UI design guideline. And the right-click context menu for the main toolbar, what's up with showing the default system menu there? Come on Microsoft, it's called a context menu for a reason -- so make it contextually viable at least.

And why does it take forever to load IE7 and render a simple page? I haven't found a good example yet where IE7 beats either Opera or Firefox in this regard.

On a 'positive' note (if you want to call it that), I can still use IE7 to retrieve Windows Updates -- since it's still ActiveX capable. At least the security enhancements in IE7 are a bit improved over IE6, which is probably why IE7 is listed as a "High priority update" now.

Anyhow, as you may know, I'm sticking with Opera.

Although, my advice to Microsoft is: keep up the effort. Perhaps someday IE7, 8, or 9 may actually compete in the browser realm, but it isn't ready today.

UserJS to fix NFL.com RealPlayer video

, , , ...

For whatever reason, Opera disallows calling the DoStop(), DoPlay(), etc methods of the RealPlayer plug-in on nfl.com -- perhaps for security reasons, since the script which injects the tag is located on images.nfl.com, but the homepage is on www.nfl.com.

Anyhow, this latest script provides a work-around by rewriting the HTML inside the tag hosting the RealPlayer plug-in. In essence, it simply sets the autoplay attribute to true, which allows the video to play when users click a video link.

Download/view the nfl.js script
if (document.domain.match(/^(www\.|images\.)?nfl\.com$/)) {
  window.opera.defineMagicFunction("goMovie",
    function (a,b,selection) {
      var videoplayer = document.getElementById("videoplayer");
      if (!videoplayer) return;
      videoplayer.innerHTML = '<PARAM name="autostart" value="true"/> \
        <PARAM name="controls" value="imagewindow"/> \
        <PARAM name="src" value="' + selection + '"/> \
        <PARAM name="console" value="cons"/> \
        <PARAM name="nologo" value="true"/> \
        <EMBED name="videoplayer" type="audio/x-pn-realaudio-plugin" width="240" height="180" nologo="true" src="' + selection + '" controls="imagewindow" autostart="true" console="cons"/>';
    });
}

To learn how to install this User JavaScript, visit UserJS.org

Enjoy.

UserJS to fix Yahoo! Football Play by Play

, , , ...

Yes, Yahoo! stinks when it comes to web coding. Simply right-click any of their pages in Opera, select "Validate", and then watch the markup errors pile-up.

Anyhow, this latest script fixes their NFL and NCAA football play by play display in Opera.

For example:

yahooNFL.js
if (document.domain.match(/^sports\.yahoo\.com$/) && 
  window.location.href.match(/&page=plays/)) {
  document.addEventListener("load",
    function() {
      var yspMainContent = document.getElementById("yspMainContent");
      if (!yspMainContent) return;
      yspMainContent.innerHTML = yspMainContent.innerHTML.replace(/\<thead\>/gi, '<table width="560" border="0" cellpadding="0" cellspacing="0"><thead>');
      yspMainContent.innerHTML = yspMainContent.innerHTML.replace(/\<\/tbody\>/gi, '</tbody></table>');
      }, 0);
}

To learn how to install this User JavaScript, visit UserJS.org

Enjoy.

UserJS to fix Disney Channel

, , , ...

The kids discovered this one: Disney Channel blocks Opera when older versions (7.0) of Flash are installed.

Here's a really simple User JavaScript to allow Disney Channel to use Flash 7.0, etc...

disneychannel.js:
if (document.domain.match(/\.disney\.go\.com$/)) {
   window.opera.defineMagicFunction("DetectFlash",
      function(RealFunc, oThis, nversion, redirect, override) {
         return 1;
      });
}

Enjoy kiddies.

UserJS to fix NetFlix shrinking buttons

, , , ...

I've updated my initial NetFlix UserJS script to version 2.0. This new version includes a fix for their shrinking form buttons. You can view or download the new version from here, or simply copy-and-paste the relevant code fix for the shrinking buttons here:

if (document && 
    document.domain && 
    document.domain.match(/^(www\.)?netflix\.com$/)) { 

  document.addEventListener("load", 
    function(e) { 
      var inps = document.getElementsByTagName("INPUT"); 
      for (var n = 0, i; i = inps[ n ]; n++) { 
        if (!i.onmouseover && !i.onmouseout) continue; 
 
        var cn = i.className; 
        if ((cn != "bsub_primary") && 
            (cn != "bsub_secondary")) continue; 
 
        i.className = ""; 
        i.style.width = "auto"; 
        i.className = cn; 
      } 
    }, false);

}


For my fellow NetFlix subscribers, enjoy!

Opening file types without opening new page

, , , ...

For those of you who hate to see a "Blank page" appear when clicking links for certain file types, I present the following User JavaScript file...

Download/view pdfHandler.js
document.addEventListener("load",
  function(e) {
    if (!document.body) document.body = document.getElementsByTagName("body")[0];
    if (!document.body) return;
    if (!document.links) return;
    for (var i = 0; i < document.links.length; i++) {
      var href = document.links[ i ].getAttribute("href");
      if (!href) continue;
      if (!href.match(/\.pdf$/) &&
          !href.match(/\.doc$/) &&
          !href.match(/\.xls$/))
          continue;

      if (!document.blankIframeHandler) {
        document.blankIframeHandler = document.createElement("iframe");
        with (document.blankIframeHandler) {
          setAttribute("src", "about:blank");
          setAttribute("id", "blankIframeHandler");
          setAttribute("name", "blankIframeHandler");
          setAttribute("style", "display:none;visibility:hidden;");
        }
        document.body.appendChild(document.blankIframeHandler);
      }
      document.links[ i ].setAttribute("target", "blankIframeHandler");
    }
  }, false);


This User JavaScript creates a hidden inline frame (iframe element) on the current page, then targets all .pdf, .doc, and .xls links to open inside that hidden inline frame.

This technique seems fairly effective at opening file types with associated programs in Opera, such as .pdf files for Adobe Reader.

Enjoy.