// ==UserScript== // @include http://www.writely.com/* // @include https://www.writely.com/* // @include http://docs.google.com/* // @include https://docs.google.com/* // @include http://*.spreadsheets.google.com/* // @include https://*.spreadsheets.google.com/* // @include http://spreadsheets.google.com/* // @include https://spreadsheets.google.com/* // @include http://www.google.com/calendar* // @include https://www.google.com/calendar* // @include http://picasaweb.google.com/* // @include https://picasaweb.google.com/* // ==/UserScript== (function( opera ){ var hostname = location.hostname; var pathname = location.pathname; if( hostname.indexOf("spreadsheets")>=0 ){ if( navigator.userAgent.indexOf("Opera") >=0 ) alert( "This website is blocking your web browser. To prevent further annoyances, right-click the page, choose 'Edit Site "+ "Preferences', go to the Network tab, and select 'Mask as Internet Explorer'. Then refresh the page."); //spreasheets only works when masked as IE (probably they use capturing event listeners) //but then it uses filters to render transparent pngs. navigator.userAgent='msie'; addCssToDocument( 'div.dlgAlert,div.dlgOpen{background-image:url(http://www.google.com/images/spreadsheets/openDlgBack.png)!important}'+ '#modalDialogBackground{background-image:url(http://www.google.com/images/spreadsheets/modalDlgBack.png)!important}'+ 'textarea.editBoxIE{font-family:Arial,inherit!important}' ); //fix for wheel scrolling wrongwards. Moving down goes up and vice-versa function copyObj(src,dest){for(var prop in src)dest[prop]=src[prop];return dest;}; opera.addEventListener('BeforeEventListener.mousewheel',function(e){ var newe = copyObj(e,{}); newe.wheelDelta = -newe.wheelDelta; e.preventdefault(); e.listener.call(e.currentTarget,newe); },false); } else if( pathname.indexOf("calendar/render")>=0 ){ if( opera ) opera.addEventListener('BeforeScript',function(e){ e.element.text=e.element.text.replace("'mozilla'","' '"); opera.removeEventListener('BeforeScript',arguments.callee,false); },false); else{ navigator.userAgent='mozilla'; Document.prototype.getBoxObjectFor=function(node){ var left=0, up=0, width=node.offsetWidth, height=node.offsetHeight; while(node.offsetParent){left+=node.offsetLeft;up+=node.offsetTop;node=node.offsetParent} return {x:left,y:up,width:width,height:height}; }; } addCssToDocument('#gridcontainer{overflow:auto!important}'); } else if( hostname == "picasaweb.google.com" ){ //bad browser sniffing - slideshow now works too. if( opera ) opera.defineMagicVariable('_c',function(){return true;},null); else navigator.userAgent = "Oprah gecko"; } else if( hostname == "docs.google.com" ){ //override sniffing var newsearch = location.search.replace('action=unsupported_browser', 'browserok=true'); if( location.search != newsearch ) location.search = newsearch; //fix for mouse coordinates for context menu document['all']=null; //prevent document from scrolling up on save, and spellcheck function resetViewPos(f,t,a,b,c){ var docEl = window.top.wys_frame.document.documentElement; var top = docEl.scrollTop; var left = docEl.scrollLeft; f.call(t,a,b,c); editorFrame.scrollTo(left,top); } opera.defineMagicFunction('ReplaceInnerHTML',resetViewPos); opera.defineMagicFunction('CorrectSpelling',resetViewPos); //fix for spell check menu position - Opera bug this time opera.defineMagicFunction('getMenuOffsets',function(f,t,mp,os){ var res = f.call(t,mp,false); if(window.top.wys_frame){ var b = window.top.wys_frame.document.body; res.x -= b.scrollLeft; res.y -= b.scrollTop; } return res; }); //call beforeunload addEventListener('unload',function(ev){ var js = document.body.getAttribute('onbeforeunload'); if( js ) eval('(function(){'+js+'}).call(document.body,ev);') },false); //an alert called somewhere without parameters, when using the remove formatting functions var alert = window.alert window.alert = function(){if(arguments.length!=0)alert.apply(this,arguments);} //function GetWYSIWYGSelection //file http://docs.google.com/javascript/EditorCommon.js?v=dgw, line 1342 //checks first for document.selection, which is only a TextRange //must check for window.getSelection ! document['selection']=undefined; //function DoInsertPageBreak //file http://docs.google.com/javascript/EditorToolbar.js?v=cpt, line 1137 //P element must have a child to be inserted var execCommand = Document.prototype.execCommand; Document.prototype.execCommand = function(command,showGui,arg){ return execCommand.call(this,command,showGui, (command=='insertHTML'&&(/
<','> <'):arg); }; if(top==self){ //sometimes clicking Edit HTML link doesn't show the correct page addEventListener('DOMContentLoaded',function(){ var edithtml=document.selectSingleNode('//td[@class="main"]/nobr/a[@class="smalllink"]'); if( edithtml && edithtml.getAttribute('href')=='#' ){ edithtml.href='javascript:'+edithtml.getAttribute('onclick').replace(/\d+;/g,'%22'); } },false); //top left links bar addCssToDocument('#savingDiv+div>table>tbody>tr>td[valign="top"]{width:400px!important}body{height:100%;margin:0}'); } else{ addCssToDocument('html,body{overflow:auto!important}'); if( top.location.href.indexOf("Edit?tab=htmledit")>0 ) //style the markup as monospace, and allow it to breaks into several lines. addCssToDocument('body{font-family:monospace!important;font-size:90%!important;white-space:pre-wrap!important}'); } } function addCssToDocument(cssText,mediaStr,doc){doc=doc||document;mediaStr=mediaStr||'all';var styles=addCssToDocument.styleObj;if(!styles){var head=doc.getElementsByTagName("head")[0];if(!head){var docEl=doc.getElementsByTagName("html")[0]||doc.documentElement;if(!docEl){doc.addEventListener(opera&&opera.version()>=9?'DOMContentLoaded':'load',function(){addCssToDocument(cssText,mediaStr,doc);},false);return;}head=doc.createElement("head");if(head)docEl.insertBefore(head,docEl.firstChild);else head=docEl;}styles=addCssToDocument.styleObj=doc.createElement("style");styles.setAttribute("type","text/css");styles.appendChild(doc.createTextNode(''));head.appendChild(styles)}styles.firstChild.nodeValue+='@media '+mediaStr+'{'+cssText+'}\n';return true;} function cloneObject(src,dest){dest=dest||{};for(var prop in src)dest[prop]=src[prop];return dest;}; })( window.opera );