search-in-Github-Star-Page

Github Star 页增加搜索框

  1. // ==UserScript==
  2. // @name search-in-Github-Star-Page
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Github Star 页增加搜索框
  6. // @author GallenHu
  7. // @match https://github.com/*?tab=stars
  8. // @grant none
  9. // @require https://cdn.staticfile.org/jquery/1.12.2/jquery.min.js
  10. // ==/UserScript==
  11.  
  12. (function () {
  13. 'use strict';
  14.  
  15. const username = document.querySelector('meta[property="profile:username"]').getAttribute('content');
  16. const htmlStr = `<form data-pjax="true" style="margin-right: 80px;" action="https://github.com/${username}?tab=stars" accept-charset="UTF-8" method="get">
  17. <div class="d-md-none">
  18. <input type="search" name="q" value="" class="form-control width-full" placeholder="Find repositories…" aria-label="Find repositories…" autocapitalize="off" autocomplete="off">
  19. <button type="submit" class="btn mt-1">
  20. <svg class="octicon octicon-search" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M11.5 7a4.499 4.499 0 11-8.998 0A4.499 4.499 0 0111.5 7zm-.82 4.74a6 6 0 111.06-1.06l3.04 3.04a.75.75 0 11-1.06 1.06l-3.04-3.04z"></path></svg>
  21. Search
  22. </button>
  23. </div>
  24. <div class="input-group d-none d-md-table">
  25. <input type="search" name="q" value="" class="form-control" placeholder="Find repositories…" aria-label="Find repositories…" autocapitalize="off" autocomplete="off">
  26. <span class="input-group-button">
  27. <button type="submit" class="btn" aria-label="Search">
  28. <svg class="octicon octicon-search" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M11.5 7a4.499 4.499 0 11-8.998 0A4.499 4.499 0 0111.5 7zm-.82 4.74a6 6 0 111.06-1.06l3.04 3.04a.75.75 0 11-1.06 1.06l-3.04-3.04z"></path></svg>
  29. </button>
  30. </span>
  31. </div>
  32. </form>`
  33.  
  34. $(htmlStr).insertAfter('.application-main .col-lg-9 h2');
  35. })();