SHARE
TWEET

Untitled

a guest Mar 25th, 2016 738 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name iichan.hk search
  3. // @description iichan.hk search
  4. // @author :^)
  5. // @version 0.1.1
  6. // @include http://iichan.hk/*
  7. // @exclude http://iichan.hk/n/list*
  8. // @grant none
  9.  
  10. // ==/UserScript==
  11. (function() {
  12.   'use strict';
  13.  
  14.   var searchbox = document.createElement('gcse:searchbox'),
  15.       searchresults = document.createElement('gcse:searchresults'),
  16.       searchlink = document.createElement('a'),
  17.       searchbar = document.createElement('div'),
  18.       resultsContainer = document.createElement('div'),
  19.       adminbar = document.getElementsByClassName('adminbar')[0],
  20.       logo = document.getElementsByClassName('logo')[0],
  21.       boardname = document.location.pathname.split('/')[1];
  22.  
  23.   if (!(adminbar || logo)) return;
  24.  
  25.   searchlink.href = '#';
  26.   searchlink.textContent = 'Поиск';
  27.   searchlink.id = 'search-link';
  28.   adminbar.innerHTML += ' [' + searchlink.outerHTML + ']';
  29.  
  30.   searchbar.id = 'search-bar';
  31.   searchbar.appendChild(searchbox);
  32.   searchbar.style.display = 'none';
  33.   searchbar.style.width = '300px';
  34.   searchbar.style.margin = '5px';
  35.   searchbar.style.cssFloat = 'right';
  36.   adminbar.innerHTML += '<br>';
  37.   adminbar.appendChild(searchbar);
  38.  
  39.   resultsContainer.style.display = 'none';
  40.   resultsContainer.id = 'results-container';
  41.   resultsContainer.appendChild(searchresults);
  42.   document.body.insertBefore(resultsContainer, logo);
  43.  
  44.   searchbox.setAttribute('defaultToRefinement', boardname);
  45.  
  46.   document.getElementById('search-link')
  47.     .addEventListener('click', function(e) {
  48.       e.preventDefault();
  49.  
  50.       var searchbar = document.getElementById('search-bar');
  51.       if (searchbar.style.display=='none')
  52.         searchbar.style.display = 'block';
  53.       else
  54.         searchbar.style.display = 'none';
  55.  
  56.       var resultsContainer = document.getElementById('results-container');
  57.       if (resultsContainer.style.display=='none')
  58.         resultsContainer.style.display = 'block';
  59.       else
  60.         resultsContainer.style.display = 'none';
  61.     });
  62.  
  63.     var cx = '016509237818063101895:p522qbpqjui';
  64.     var gcse = document.createElement('script');
  65.     gcse.type = 'text/javascript';
  66.     gcse.async = true;
  67.     gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
  68.         '//www.google.com/cse/cse.js?cx=' + cx;
  69.     var s = document.getElementsByTagName('script')[0];
  70.     s.parentNode.insertBefore(gcse, s);
  71. })();
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top