NaNoWriMo Promotes Manuscription
Wondering what’s next for npm?Check out our public roadmap! »

opensug

1.0.1 • Public • Published

openSug.js

Simply reference a section of openSug.js to get a search box with "search box prompts" to make your search easier! Please browse the configuration page and examples : here

Browser support: IE6+, Firefox, Chrome, Safari, Opera, Edge...

Provide the replacement result source, The default is to use Baidu result source.

Example

Simple

input type: only text or search.

action: baiduSug = 1 or true : Automatic submission, baiduSug = 2 or false : Manual submission.

// [search]Baidu.com
<input type="text" baiduSug="1|true" ... 
<input type="text" baiduSug="2|false" ... 
 
// [search]Google.com
<input type="text" google="1|true" ... 
<input type="text" google="2|false" ... 
 
// [search]So.com
<input type="text" haoso="1|true" ... 
<input type="text" haoso="2|false" ... 
 
// [music]Kugou.com
<input type="text" kugou="1|true" ... 
<input type="text" kugou="2|false" ... 
 
// [search]Yahoo.com
<input type="text" yahoo="1|true" ... 
<input type="text" yahoo="2|false" ... 
 
// [search]Yandex.ru
<input type="text" yandex="1|true" ... 
<input type="text" yandex="2|false" ... 
 
// [video]Youku.com
<input type="text" youku="1|true" ... 
<input type="text" youku="2|false" ... 
 
// [shopping]Taobao.com
<input type="text" taobao="1|true" ... 
<input type="text" taobao="2|false" ... 
 
// [video]MGTV.com
<input type="text" mgtv="1|true" ... 
<input type="text" mgtv="2|false" ... 
 
// [search]SM.cn
<input type="text" sm="1|true" ... 
<input type="text" sm="2|false" ... 
 
// [topic]Weibo.com
<input type="text" weibo="1|true" ... 
<input type="text" weibo="2|false" ... 
 
// [search]Rambler.ru
<input type="text" rambler="1|true" ... 
<input type="text" rambler="2|false" ... 
 
// [eBook]Zongheng.com
<input type="text" book="1|true" ... 
<input type="text" book="2|false" ... 
 
// [Software]QQ.com
<input type="text" soft="1|true" ... 
<input type="text" soft="2|false" ... 
 
// [search]Naver.com
<input type="text" naver="1|true" ... 
<input type="text" naver="2|false" ... 
 
// [Car]Pcauto.com.cn
<input type="text" weixin="1|true" ... 
<input type="text" weixin="2|false" ... 
 
 

Advanced

(typeof(BaiduSuggestion)=="object"&&BaiduSuggestion instanceof Object)&&BaiduSuggestion.bind("inputObj", {  // Input ID
      "XOffset": "-4",             // Proposal frame position X offset, unit px.
      "YOffset": "-5",             // Prompt box position vertical Y offset, unit px.
      "width": "",                  // Prompt box width, unit px.
      "fontColor": "#FF0000",       // Prompt text color.
      "fontColorHI": "#0000FF",     // Prompt box highlight text color when selected.
      "fontSize": "14px",           // font size
      "fontFamily": "Microsoft YaHei",    // Text fontFamily.
      "borderColor": "#008000",     // Prompt box border color.
      "bgcolorHI": "#FF6600",       // Prompt box highlights the selected color.
      "sugSubmit": true,             // Whether to submit the form when the entry in the prompt box is selected.
      "source":"google | haoso | kugou | yahoo | yandex | youku | taobao | mgtv | sm | weibo | naver | rambler | book | soft | car | [customize]" // customize = https://{URL}/?{query}=, Default Baidu.
  }, function(Callback){console.log('eg:https://{YouURL}/?conut_update='+ Callback);});

Note: Introduce Javascript files in web pages. Javascript code should be added as far as possible behind the tag in the web page.

Note: If the source page is encoded in UTF-8, be sure to set the charset="gbk" attribute in the script tag, otherwise the search hint will be garbled.

openSug.js xrea.com sug.js.org opensug.evai.pl

Install

npm i opensug

DownloadsWeekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

42.2 kB

Total Files

4

Last publish

Collaborators

  • avatar