Search developer.opentext.com with Google

Replaces the built-in search at developer.opentext.com

  1. // ==UserScript==
  2. // @name Search developer.opentext.com with Google
  3. // @namespace mailto:fprantl@opentext.com
  4. // @version 0.2
  5. // @description Replaces the built-in search at developer.opentext.com
  6. // by the Google Custom Search searching that domain only.
  7. // The URL points to my CSE but it can be modified.
  8. // The built-in AppWorks search remains available.
  9. // @match *://developer.opentext.com/*
  10. // @copyright (c) 2014 OpenText GmbH
  11. // ==/UserScript==
  12.  
  13. if (typeof $ !== undefined) {
  14. $(function () {
  15. var originalForm = $('form[action="/awd/search"]'),
  16. parent = originalForm.parent();
  17. if (originalForm) {
  18. console.log('Replacing the AppWorks search with the Google custom search...');
  19. originalForm.hide();
  20. var gcse = $('<gcse:search>').insertAfter(originalForm),
  21. switcher = $('<button>')
  22. .text('OTEX')
  23. .addClass('btn switch-gcse')
  24. .click(function () {
  25. $('div#___gcse_0').toggle();
  26. originalForm.toggle();
  27. switcher.toggleClass('switch-gcse-otex')
  28. .text(originalForm.is(':visible') ? 'GOOG' : 'OTEX');
  29. }).insertBefore(originalForm);
  30. (function() {
  31. var cx = '006791522399351765273:14trghalcz4';
  32. var gcse = document.createElement('script');
  33. gcse.type = 'text/javascript';
  34. gcse.async = true;
  35. gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
  36. '//www.google.com/cse/cse.js?cx=' + cx;
  37. var s = document.getElementsByTagName('script')[0];
  38. s.parentNode.insertBefore(gcse, s);
  39. })();
  40. $('style').html(
  41. 'div#___gcse_0 {\n' +
  42. ' display: inline-block;\n' +
  43. ' width: 25em !important;\n' +
  44. ' float: right !important;\n' +
  45. '}\n' +
  46. 'div.gsc-control-cse {\n' +
  47. ' padding: 0 !important;\n' +
  48. '}\n' +
  49. 'button.switch-gcse {\n' +
  50. ' float: right;\n' +
  51. ' margin-left: 0.5ex;\n' +
  52. ' margin-top: 2px !important;\n' +
  53. ' font-size: 75%;\n' +
  54. ' height: 27px;\n' +
  55. '}\n' +
  56. 'button.switch-gcse.switch-gcse-otex {\n' +
  57. ' margin-top: 5px !important;\n' +
  58. ' height: 29px;\n' +
  59. '}\n'
  60. ).appendTo('head');
  61. }
  62. });
  63. }