Search developer.opentext.com with Google

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

Tính đến 19-06-2014. Xem phiên bản mới nhất.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

Bạn sẽ cần cài đặt một tiện ích mở rộng như Tampermonkey hoặc Violentmonkey để cài đặt kịch bản này.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(Tôi đã có Trình quản lý tập lệnh người dùng, hãy cài đặt nó!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name       Search developer.opentext.com with Google
// @namespace  mailto:[email protected]
// @version    0.1
// @description  Replaces the built-in search at developer.opentext.com by the
//               Google Custom Search searching this domain only.  The URL points
//               to my CSE but it can be modified.
// @match      *://developer.opentext.com/*
// @copyright  (c) 2014 OpenText GmbH
// ==/UserScript==

if (typeof $ !== undefined) {
  $(function () {
    var originalForm = $('form[action="/awd/search"]'),
        parent = originalForm.parent();
    if (originalForm) {
      console.log('Replacing the AppWorks search with the Google custom search...');
      $('<gcse:search>').insertAfter(originalForm);
      originalForm.remove();
      (function() {
        var cx = '006791522399351765273:14trghalcz4';
        var gcse = document.createElement('script');
        gcse.type = 'text/javascript';
        gcse.async = true;
        gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
            '//www.google.com/cse/cse.js?cx=' + cx;
        var s = document.getElementsByTagName('script')[0];
        s.parentNode.insertBefore(gcse, s);
      })();
      $('style').html(
        'div#___gcse_0 {\n' +
        '  display: inline-block;\n' +
        '  width: 25em  !important;\n' +
        '  float: right  !important;\n' +
        '}\n' +
        'div.gsc-control-cse {\n' +
        '  padding: 0 !important;\n' +
        '}\n'
      ).appendTo('head');
    }
  });
}