Aug
20
2013

Unity Docs MiddleMouseButton New Tab

unity_documentation_open_new_tab_middle_mouse

Unity “broke” the documentation in some update..cannot middle mouse button click them to open in new tab..
http://forum.unity3d.com/threads/193569-Script-documentation-doesn-t-allow-opening-links-in-new-tab-%28ctrl-or-middle-click%29

While waiting for the fix here’s small GreaseMonkey plugin userscript (firefox) :
– It fixes the links for middle mouse button (so that they open in new tab)
– Also it fixes the page titles (to use the page file name)

// ==UserScript==
// @name        UnityDocsMiddleButton
// @namespace   unitycoder.com
// @description UnityDocsOpenMiddleButtonNewTab by UnityCoder.com
// @include     http://docs.unity3d.com/Documentation/ScriptReference/*
// @version     1.0
// ==/UserScript==

// search page
var scriptCode = new Array();
scriptCode.push('$(document).on("mousedown", ".searchres a", function(e){if(e.which== 2){');
scriptCode.push('$(this).attr("href", (location.href.substring(0,location.href.lastIndexOf("/")+1))+$(this).attr("onclick").split(";")[0].split(\'"\')[1]+".html");');
scriptCode.push('$(this).removeAttr("onclick");$(this).trigger("click");e.preventDefault();}});');
var script = document.createElement('script');
script.innerHTML = scriptCode.join('\n');
scriptCode.length = 0;
document.getElementsByTagName('body')[0].appendChild(script);

// fix most of the links by removing onclick and placing the url on href src instead..
var scriptCode = new Array();
scriptCode.push('$(document).on("mousedown", ".classRuntime a,.attrRuntime a,.enumRuntime a,.classEditor a,.enumEditor a,.attrEditor a,.decText a,.subsection a,.memberTableName a,.heading a", function(e){if(e.which== 2){');
scriptCode.push('$(this).attr("href", (location.href.substring(0,location.href.lastIndexOf("/")+1))+$(this).attr("onclick").split(";")[0].split(\"\'")[1]+".html");');
scriptCode.push('$(this).removeAttr("onclick");$(this).trigger("click");e.preventDefault();}});');
var script = document.createElement('script');
script.innerHTML = scriptCode.join('\n');
scriptCode.length = 0;
document.getElementsByTagName('body')[0].appendChild(script);

// update page title, TODO: remove ".html"?
document.title = "Docs:"+location.pathname.substring(location.pathname.lastIndexOf("/") + 1);

5 Comments + Add Comment

Leave a comment

Connect

Twitter View LinkedIn profile Youtube Github Join Discord Twitch Instagram BlueSky

UnityLauncherPro

Get UnityLauncherPRO and work faster with Unity Projects!
*free unity hub alternative

@unitycoder_com

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.