您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Add 'quick search' input and 'go to top' button for Google
当前为
// ==UserScript== // @name Quick search & Go to Top -- Google // @namespace feifeihang.info // @description Add 'quick search' input and 'go to top' button for Google // @include https://www.google.* // @include http://www.google.* // @version 4 // @grant none // ==/UserScript== (function (window, document, undefined) { var container = document.createElement('dv'); container.style = 'display: none; position: fixed; bottom: 10px;' + 'right: 10px; text-align: right;' + 'width: 260px; height: 40px; background: #343C45; z-index: 999999999;' + 'opacity: 0.8;'; // create quick query input. var input = document.createElement('input'); input.tyle = 'text'; input.value = document.querySelector('#lst-ib').value; input.setAttribute('placeholder', 'Search...'); input.style = 'display: inline-block; border: none; outline: none; width: 195px; height: 40px;' + 'font-size: 15px; padding: 0; padding-left: 10px; padding-right: 10px; background: #D9D9D9;'; container.appendChild(input); // bind keypress-enter event. input.addEventListener('keypress', function (evt) { if (evt.keyCode === 13) { var value = input.value.trim() || ''; if (value !== '') { document.querySelector('#lst-ib').value = value; document.querySelector('.lsb').click(); } } }, false); // create the goto-top button. var btn = document.createElement('div'); btn.id = 'goto-top-btn'; btn.innerHTML = 'TOP'; btn.onclick = gotoTop; // set button CSS style. btn.style = 'display: inline-block; color: #fff; line-height: 42px; text-align: center;' + 'width: 40px; height: 40px; background: #4285F4;' + 'cursor: pointer; font-weight: bolder;'; // append the go-to-top to search form to successfully attach to the UI. container.appendChild(btn); var form = document.querySelector('#searchform'); form.appendChild(container); window.onload = function () { var doc = document.documentElement; var top = (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0); if (top !== 0) { container.style.display = 'block'; } } // bind button hiden/show event. window.onscroll = function() { var doc = document.documentElement; var top = (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0); if (top === 0) { container.style.display = 'none'; } else { container.style.display = 'block'; } } function gotoTop() { goto(Math.floor(window.pageYOffset / 5)); } function goto(step) { setTimeout(function () { window.scrollTo(0, window.pageYOffset - step); if (window.pageYOffset <= 0) return; goto(step); }, 100); } })(window, document, undefined);