Click to install this script

Cool Running: Google Search

  • Added: October 27, 2007
  • Last Updated: October 27, 2007

File Name: coolrunning_google.user.js

Click to hide sectionDescription

Ah, Cool Running. You cheap, cheap bastards, unable to afford a decent server. I wrote this script, which adds a "Google Search" on the Cool pages. around the time they permanently turned off search functionality. If you're in a particular forum, the search results will be restricted to that forum; otherwise the search will be restricted to the Cool Running site. I couldn't figure out how to restrict a search to a particular topic, so the script doesn't do that. Since has purchased Cool Running, this script will probably be worthless in a few weeks (but hey, at least I got a lot of use out of it).

Click to hide sectionScript Source

// Cool Running: Google Search // Copyright (c) 2006-2007 Orbona // Version 1.0 // Release Date: 2007-10-22 // // See also: // // Original file name: coolrunning_google.user.js // Please reference the original file name when contacting me regarding this // script. // // This software is licensed under the CC-GNU GPL: // // // ---------------------------------------------------------------------------- // DESCRIPTION // // Adds a Google search to the pages on coolrunning. The Google search is // added at the top of all pages. // // If searching from the forum (e.g. Gear, Newbie Cafe) pages, searches are // performed within that forum. On any other pages, searches are performed // per site. // ---------------------------------------------------------------------------- // ==UserScript== // @name Cool Running: Google Search // @description Adds a "Google Search" to Cool Running topic pages. // @namespace // @include* // ==/UserScript== // ---------------------------------------------------------------------------- // This function intercepts the form submit. Adds the appropriate // advanced search parameters, which will restrict the search to // the site or the forum, to the user-entered query string and // then allows the submit to proceed. // ---------------------------------------------------------------------------- function googleSubmit(event) { var theForumNum; var target = event ? : this; var regexForumNum = /.+&number=(\d+).+/i; theForumNum = regexForumNum.exec( window.location.href) if (theForumNum) theForumNum = theForumNum[1]; if ('googlesearch') { if (theForumNum) target.elements[1].value += '' + theForumNum +'/HTML'; else target.elements[1].value +=' site:' +; } this._submit(); } // ---------------------------------------------------------------------------- // Main function that does everything described in the description area above. // ---------------------------------------------------------------------------- function doIt() { var mainElem = document.getElementsByName('m_nav_home'); var activeHeader, googleSearchElem, inputElemH1, inputElemSearch, submitElem; var links=document.evaluate("//A[contains(@href,'')]", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); if (links.snapshotLength > 0) activeHeader = links.snapshotItem(0); if (mainElem && mainElem[0]) { mainElem = mainElem[0]; if (activeHeader) { var activeLink = document.createElement('a'); activeLink.href= activeHeader.href; '3em'; activeLink.innerHTML = 'Visit'; activeHeader.parentNode.removeChild(activeHeader); mainElem.parentNode.insertBefore(activeLink, mainElem); } googleSearchElem = document.createElement('form'); googleSearchElem.action = ''; 'googlesearch'; = 'inline'; inputElemH1=document.createElement('input'); inputElemH1.type='hidden';'h1'; inputElemH1.value='en'; inputElemSearch=document.createElement('input');'q'; inputElemSearch.maxlength='2048'; inputElemSearch.size='25'; inputElemSearch.title='GoogleSearch'; submitElem=document.createElement('input'); submitElem.type='submit';'btnG'; submitElem.value='Google Search'; googleSearchElem.appendChild(inputElemH1); googleSearchElem.appendChild(inputElemSearch); googleSearchElem.appendChild(submitElem); googleSearchElem.addEventListener('submit', googleSubmit, true); //no need to redefine method of HTMLFormElement class since //no other scripts should be submitting my brand-spankin-new form mainElem.parentNode.insertBefore(googleSearchElem, mainElem); } } // ------------------END OF FUNCTIONS ----------------------------- window.addEventListener("load", function() { doIt(); }, false);