// ==UserScript== // @include http://*.spreadsheets.google.com/* // @include https://*.spreadsheets.google.com/* // @include http://spreadsheets.google.com/* // @include https://spreadsheets.google.com/* // ==/UserScript== (function(){ if(navigator.userAgent.indexOf('Opera') != -1) { alert('Google Spreadsheets is blocking Opera. \nDo the following to fix it:\n\n' + '1. Right click the page and choose Edit Site Preferences\n' + '2. Choose the Network tab\n' + '3. From Browser identification, choose Mask as Firefox\n' + '4. Reload the page'); return; } //Attempt to repair Spreadsheets' browser detection window.opera.addEventListener('AfterScript',function(ev){ if(!ev.element.src || ev.element.src.indexOf('trix_core.js') == -1) { return; } var func = getBrokenFunction(ev.element.text); if(func == null) return; window.opera.defineMagicFunction(func, function(){ return true; }); }, false); //Fix buggy cell editor style window.addEventListener('DOMContentLoaded', function(ev){ var style = document.createElement('style'); style.setAttribute('type', 'text/css'); var css = '.editBoxWrapper { overflow: hidden !important; }'; style.innerHTML = css; document.getElementsByTagName('head')[0].appendChild(style); }, false); /** * Attempts to locate the broken function in the spreadsheets * code that's breaking Opera support * @param string code * @return string|null function name or null on failure */ function getBrokenFunction(code) { var rex = new RegExp( '_getInstanceOfApp\([^)]+\)[^{]*\{' + //Match start of function '[^}]+' + //Match function contents '\}', //Match function end 'm'); var match = rex.exec(code); if(!match) return null; var funcStr = match[0]; rex = /if\(([^(]+)/im; //Match if clause and a function name inside it match = rex.exec(funcStr); if(!match[1]) return null; return match[1]; } })();