GitHub Search Autocomplete

A userscript that adds autocomplete search filters to GitHub

Verze ze dne 01. 07. 2023. Zobrazit nejnovější verzi.

  1. // ==UserScript==
  2. // @name GitHub Search Autocomplete
  3. // @version 1.0.2
  4. // @description A userscript that adds autocomplete search filters to GitHub
  5. // @license MIT
  6. // @author Rob Garrison
  7. // @namespace https://github.com/Mottie
  8. // @match https://github.com/*
  9. // @match https://gist.github.com/*
  10. // @run-at document-idle
  11. // @grant GM_addStyle
  12. // @require https://code.jquery.com/jquery-3.2.1.min.js
  13. // @require https://cdnjs.cloudflare.com/ajax/libs/Caret.js/0.3.1/jquery.caret.min.js
  14. // @require https://cdnjs.cloudflare.com/ajax/libs/at.js/1.5.4/js/jquery.atwho.min.js
  15. // @icon https://github.githubassets.com/pinned-octocat.svg
  16. // @supportURL https://github.com/Mottie/GitHub-userscripts/issues
  17. // ==/UserScript==
  18. (($) => {
  19. "use strict";
  20.  
  21. const data = {},
  22.  
  23. // search input classes used by GitHub
  24. selectors = [
  25. ".header-search-input", // main header search
  26. "[aria-label*='Search']", // https://github.com/search
  27. ".search-page-input", // https://github.com/search/advanced
  28. "#js-issues-search", // https://github.com/:user/:repo/issues & pulls
  29. ".js-search-query" // https://gist.github.com/search?q=css
  30. ].join(","),
  31.  
  32. // update examples using current & previous year
  33. year = new Date().getFullYear(),
  34. /**
  35. * This data was manually extracted from the pages listed on
  36. * https://help.github.com/categories/search/
  37. */
  38. filters = {
  39. "AND": {
  40. "": "search operator (max 5 of any operator)"
  41. },
  42. // Issue
  43. "assignee": {
  44. "": "search for issues assigned to the named user",
  45. "fred": 'search for issues assigned to "@fred"'
  46. },
  47. // Commits & Issues
  48. "author": {
  49. "": "search for issues or commits authored by the username",
  50. "fred": 'search for issues or commits authored by "@fred"'
  51. },
  52. "author-date": {
  53. "": "search commits authored before or after a date",
  54. ">${year-1}-12-31": "search commits authored since ${year}",
  55. ">=${year}-01-01": "search commits authored since ${year}",
  56. "<${year}-01-01": "search commits authored before ${year}",
  57. "<=${year-1}-12-31": "search commits authored before ${year}"
  58. },
  59. "author-email": {
  60. "": "search for a commit authored by the specified user email",
  61. "fred@gmail.com": "search for commits authored by gmail fred"
  62. },
  63. "author-name": {
  64. "": "search for a commit created using the author's actual name",
  65. "smith": 'search for commits authored by someone named "smith"'
  66. },
  67. // Issues
  68. "base": {
  69. "": "search pull requests to be merged into the specified branch name",
  70. "gh-pages": 'search pull requests being merged into the "gh-pages" branch'
  71. },
  72. // Issues
  73. "closed": {
  74. "": "search issues & pull requests closed before or after a date",
  75. ">${year-1}-12-31": "search issues & pull requests closed since ${year}",
  76. ">=${year}-01-01": "search issues & pull requests closed since ${year}",
  77. "<${year}-01-01": "search issues & pull requests closed before ${year}",
  78. "<=${year-1}-12-31": "search issues & pull requests closed before ${year}"
  79. },
  80. "commenter": {
  81. "": "search for comments authored by the named user",
  82. "fred": 'search for comments authored by "@fred"'
  83. },
  84. "comments": {
  85. "": "search issues with specified number of comments",
  86. "100": "search issues with exactly 100 comments",
  87. ">100": "search issues with >100 comments",
  88. ">=100": "search issues with >=100 comments",
  89. "10..20": "search issues with 10-20 comments",
  90. "<100": "search issues with <100 comments",
  91. "<=100": "search issues with <=100 comments"
  92. },
  93. "committer": {
  94. "": "search for commits authored by the named user",
  95. "fred": 'search for commits authored by "@fred"'
  96. },
  97. "committer-date": {
  98. "": "search commits authored before or after a date",
  99. ">${year-1}-12-31": "search commits authored since ${year}",
  100. ">=${year}-01-01": "search commits authored since ${year}",
  101. "<${year}-01-01": "search commits authored before ${year}",
  102. "<=${year-1}-12-31": "search commits authored before ${year}"
  103. },
  104. "committer-email": {
  105. "": "search for a commit authored by the specified user email",
  106. "fred@gmail.com": "search for commits authored by gmail fred"
  107. },
  108. "committer-name": {
  109. "": "search for a commit created using the author's actual name",
  110. "smith": 'search for commits authored by someone named "smith"'
  111. },
  112. // Issues & user
  113. "created": {
  114. "": "search issues & user accounts created at the specified date",
  115. ">${year-1}-12-31": "search issues & user accounts created since ${year}",
  116. ">=${year}-01-01": "search issues & user accounts created since ${year}",
  117. "${year}-01-01..*": "search issues & user accounts created since ${year}",
  118. "${year}-01-01..${year}-01-31": "search commits authored in Jan ${year}",
  119. "<${year}-01-01": "search issues & user accounts created before ${year}",
  120. "<=${year-1}-12-31": "search issues & user accounts created before ${year}",
  121. "*..${year-1}-12-31": "search issues & user accounts created before ${year}"
  122. },
  123. // Code
  124. "extension": {
  125. "": "search within file extensions",
  126. "js": "search within JavaScript files",
  127. "rb": "search within Ruby files",
  128. "css": "search within CSS files",
  129. "coffee": "search within CoffeeScript files",
  130. "md": "search within markdown files"
  131. },
  132. "-extension": {
  133. "": "search excludes this file extension",
  134. "js": "search excludes JavaScript files",
  135. "rb": "search excludes Ruby files",
  136. "css": "search excludes CSS files",
  137. "coffee": "search excludes CoffeeScript files",
  138. "md": "search excludes markdown files"
  139. },
  140. // Code
  141. "filename": {
  142. "": "search within code files named as specified",
  143. "test_helper": 'search within the "test_helper" code file(s)',
  144. ".vimrc": 'search "*.vimfc*" code files named as specified'
  145. },
  146. // User
  147. "followers": {
  148. "": "search users & organizations with the specified number of followers",
  149. "100": "search users with exactly 100 followers",
  150. ">100": "search users with >100 followers",
  151. ">=100": "search users with >=100 followers",
  152. "10..20": "search users with 10-20 followers",
  153. "<100": "search users with <100 followers",
  154. "<=100": "search users with <=100 followers"
  155. },
  156. // Code... includes "-fork"?
  157. "fork": {
  158. "": "searches exclude forks when this filter is undefined",
  159. "only": "search only within forked repos",
  160. "true": "search includes forked repos"
  161. },
  162. // Repos, Code
  163. "forks": {
  164. "": "search repos with greater, less, or a range of forks",
  165. "100": "search repos with exactly 100 forks",
  166. ">100": "search repos with >100 forks",
  167. ">=100": "search repos with >=100 forks",
  168. "10..20": "search repos with 10-20 forks",
  169. "<100": "search repos with <100 forks",
  170. "<=100": "search repos with <=100 forks"
  171. },
  172. "-forks": {
  173. "": "search repos outside of the selected number of forks",
  174. "100": "search repos with that do not have exactly 100 forks",
  175. ">100": "search repos with <=100 forks",
  176. ">=100": "search repos with <100 forks",
  177. "10..20": "search repos with <10 or >20 forks",
  178. "<100": "search repos with >=100 forks",
  179. "<=100": "search repos with >100 forks"
  180. },
  181. "fullname": {
  182. "": "search within a user's full name",
  183. "linus": 'search for users with "linus" in their full name',
  184. '"Linus Torvalds"': "search for a full name wrapped in quotes"
  185. },
  186. // Commits
  187. "hash": {
  188. "": "search commits with the specified SHA-1 hash",
  189. "124a9a0ee1d8f1e15e833aff432fbb3b02632105": "search matching hash"
  190. },
  191. // Issues
  192. "head": {
  193. "": "search pull requests opened from the specified branch name",
  194. "fix": 'search pull requests opened from branch names containing the word "fix"'
  195. },
  196. // Repos, Issue, User
  197. "in": {
  198. "": "search within repo, issue or user meta data",
  199. // Repo
  200. "body": "search within an issue or wiki body",
  201. "description": "search within the repo description",
  202. "file": "search within the repo file contents",
  203. "file,path": "search within the repo file contents & path name",
  204. "name": "searh within a user, organization or repo name",
  205. "name,description" : "search within the repo name or description",
  206. "path": "search within the repo path name",
  207. "readme": "search within the repo readme",
  208. // Issue & Wiki
  209. "comments": "search within an issue comments",
  210. "title": "search within an issue or wiki title",
  211. "title,body": "search within an issue or wiki title & body",
  212. // User
  213. "email": "search within a user or organization email (not the domain name)",
  214. "login": "search within a user or organization username",
  215. "fullname": "search within a user's full name"
  216. },
  217. "involves": {
  218. "": "search for issues or commits that involves the named user",
  219. "fred": 'search for issues or commits that involve "@fred"'
  220. },
  221. // Commits
  222. "is": {
  223. "": "search commits and issues of the specified state (multiple allowed)",
  224. "public": "search public commits & issues",
  225. "private": "search private commits & issues",
  226. "open": "search open issues & pull requests",
  227. "closed": "search closed issues & pull requests",
  228. "issue": "search within issues",
  229. "pr": "search within pull requests",
  230. "merged": "search merged pull requests",
  231. "unmerged": "search unmerged pull requests"
  232. },
  233. // Issue
  234. "label": {
  235. "": "search issues & pull requests with the specified label (multiple allowed)",
  236. "bug": 'search for issues & pull requests labeled "bug"',
  237. '"in progress"': "search for multiword labels inside quotes"
  238. },
  239. "-label": {
  240. "": "search issues & pull requests without the specified label",
  241. "bug": 'search for issues & pull requests not labeled "bug"'
  242. },
  243. // Code, Issue, Repos, User
  244. "language": {
  245. "": "search within this language",
  246. "javascript": "search within repos containing JavaScript",
  247. "php": "search within repos containing PHP",
  248. "scss": "search within repos containing SCSS",
  249. "c#": "search within repos containing C#",
  250. "markdown": "search within repos containing markdown (.md, .markdown, etc)",
  251. },
  252. "-language": {
  253. "": "search excludes this language",
  254. "javascript": "search excludes repos with JavaScript",
  255. "php": "search excludes repos with PHP",
  256. "scss": "search excludes repos with SCSS",
  257. "xml": "search excludes repos with XML",
  258. "markdown": "search excludes repos with markdown (.md, .markdown, etc)",
  259. },
  260. "location": {
  261. "": "search users within a location",
  262. '"San Francisco, CA"': "search users in San Francisco",
  263. "london": "search users in london",
  264. "iceland": "search users in Iceland"
  265. },
  266. "-location": {
  267. "": "search users not in a specific location",
  268. '"San Francisco, CA"': "search users not in San Francisco",
  269. "london": "search users not in london",
  270. "iceland": "search users not in Iceland"
  271. },
  272. // Issues
  273. "mentions": {
  274. "": "search for issues mentioning the named user",
  275. "fred": 'search for issues that mention "@fred"'
  276. },
  277. // Commits
  278. "merge": {
  279. "true": "searches that match merge commits",
  280. "false": "searches that match non-merge commits"
  281. },
  282. "merged": {
  283. "": "search pull requests merged at the specified date",
  284. ">${year-1}-12-31": "search pull requests merged since ${year}",
  285. ">=${year}-01-01": "search pull requests merged since ${year}",
  286. "<${year}-01-01": "search pull requests merged before ${year}",
  287. "<=${year-1}-12-31": "search pull requests merged before ${year}"
  288. },
  289. "milestone": {
  290. "": "search for issues & pull requests within the specified milestone",
  291. "sprint-42": 'search for issues & pull requests in the "sprint-42" milestone'
  292. },
  293. "no": {
  294. "": "search issues & pull requests missing the specified association",
  295. "label": "search issues & pull requests that don't have a label",
  296. "assignee": "search issues & pull requests that don't have an assignee",
  297. "milestone": "search issues & pull requests that don't have a milestone",
  298. "project": "search issues & pull requests that don't have a project"
  299. },
  300. "NOT": {
  301. "": "search operator (max 5 of any operator)"
  302. },
  303. "OR": {
  304. "": "search operator (max 5 of any operator)"
  305. },
  306. "org": {
  307. "": "search within the named organization",
  308. "github": "search GitHub's repositories"
  309. },
  310. // Commits
  311. "parent": {
  312. "": "search children of specified SHA-1 hash",
  313. "124a9a0ee1d8f1e15e833aff432fbb3b02632105": "search children of hash"
  314. },
  315. "path": {
  316. "": "search code within the specific file path (directory)",
  317. "cgi-bin": 'search code within the "cgi-bin" folder',
  318. "test/spec": "search code within sub-folders"
  319. },
  320. "project": {
  321. "": "search issues within a specified repository project board",
  322. "github/linguist/1": "search issues in GitHub's linguist repo project board 1"
  323. },
  324. // Repos
  325. "pushed": {
  326. "": "search repo pushes before or after a date (no range)",
  327. ">${year}-01-15": "search repos pushed to after Jan 15, ${year}",
  328. ">=${year}-01-15": "search repos pushed to since Jan 15, ${year}",
  329. "<${year}-02-01": "pushed to before Feb ${year}",
  330. "<=${year}-02-01": "pushed to before and including Feb 1, ${year}"
  331. },
  332. "-pushed": {
  333. "": "search pushes opposite of selected dates (no range)",
  334. ">${year}-01-15": "search repos pushed to after Jan 15, ${year}",
  335. ">=${year}-01-15": "search repos pushed to since Jan 15, ${year}",
  336. "<${year}-02-01": "pushed to before Feb ${year}",
  337. "<=${year}-02-01": "pushed to before and including Feb 1, ${year}"
  338. },
  339. // Commits
  340. "repo": {
  341. "": "search within the specified user's repository",
  342. "torvalds/linux": "search commits within Linus' Linux repository"
  343. },
  344. "repos": {
  345. "": "search user or organization with specified number of repos",
  346. "100": "search user or org with exactly 100 repos",
  347. ">100": "search user or org with >100 repos",
  348. ">=100": "search user or org with >=100 repos",
  349. "10..20": "search user or org with 10-20 repos",
  350. "<100": "search user or org with <100 repos",
  351. "<=100": "search user or org with <=100 repos"
  352. },
  353. "review": {
  354. "": "search pull requests with the specified review state",
  355. "none": "search pull requests that have not been reviewed",
  356. "required": "search pull requests that require a review before merge",
  357. "approved": "search pull requests that have been approved",
  358. "changes_requested": "search pull requests where a reviewer requested changes"
  359. },
  360. "review-requested": {
  361. "": "search pull requests with a requested reviewer, but only before they review the PR",
  362. "fred": 'search pull requests where "@fred" was asked to review'
  363. },
  364. "reviewed-by": {
  365. "": "search pull requests that have been reviewed by the specified user",
  366. "fred": 'search pull requests reviewed by "@fred"'
  367. },
  368. // Repos, Code - include "-size"?
  369. "size": {
  370. "": "search repos or files with a specific size (in KB)",
  371. "1000": "search repos or files that are exactly 1 MB in size",
  372. ">10000": "search repos or files that are more than 10 MB in size",
  373. ">=10000": "search repos or files that are at least 10 MB in size",
  374. "1024..4096": "search repos or files between 1024 and 4096 KB in size",
  375. "<1000": "search repos or files less than 1 MB in size",
  376. "<=100": "search repos or files that are less than or equal to 100 KB in size"
  377. },
  378. "sort": {
  379. "": 'apply an ascending or descending sort to the specified filter; add "-asc" or "-desc"',
  380. "author-date-asc": "sort oldest authored date first",
  381. "author-date-desc": "sort newest authored date first",
  382. "comments-asc": "sort least comments fist",
  383. "comments-desc": "sort most comments first",
  384. "committer-date-asc": "sort oldest committer date first",
  385. "committer-date-desc": "sort newest committer date first",
  386. "created-asc": "sort oldest item first",
  387. "created-desc": "sort newest item first",
  388. "forks-asc": "sort least forks first",
  389. "forks-desc": "sort most forks first",
  390. "reactions-+1-asc": "sort least +1 reactions first",
  391. "reactions-+1-desc": "sort most +1 reactions first",
  392. "reactions--1-asc": "sort least -1 reactions first",
  393. "reactions--1-desc": "sort most -1 reactions first",
  394. "reactions-heart-asc": "sort least heart reactions first",
  395. "reactions-heart-desc": "sort most heart reactions first",
  396. "reactions-smile-asc": "sort least smile reactions first",
  397. "reactions-smile-desc": "sort most smile reactions first",
  398. "reactions-tada-asc": "sort least tada reactions first",
  399. "reactions-tada-desc": "sort most tada reactions first",
  400. "reactions-thinking_face-asc": "sort least thinking face reactions first",
  401. "reactions-thinking_face-desc": "sort most thinking face reactions first",
  402. "stars-asc": "sort least stars first",
  403. "stars-desc": "sort most stars first",
  404. "updated-asc": "sort least recently updated first",
  405. "updated-desc": "sort recently updated first"
  406. },
  407. "stars": {
  408. "": "search repos with greater, less, or a range of stars",
  409. "100": "search repos with exactly 100 stars",
  410. ">100": "search repos with >100 stars",
  411. ">=100": "search repos with >=100 stars",
  412. "10..20": "search repos with 10-20 stars",
  413. "<100": "search repos with <100 stars",
  414. "<=100": "search repos with <=100 stars"
  415. },
  416. "-stars": {
  417. "": "search repos outside of the selected number of stars",
  418. "100": "search repos with that do not have exactly 100 stars",
  419. ">100": "search repos with <=100 stars",
  420. ">=100": "search repos with <100 stars",
  421. "10..20": "search repos with <10 or >20 stars",
  422. "<100": "search repos with >=100 stars",
  423. "<=100": "search repos with >100 stars"
  424. },
  425. "state": {
  426. "closed": "search closed issues",
  427. "open": "search open issues"
  428. },
  429. "status": {
  430. "": "search pull requests with the specified status",
  431. "success": "search pull requests with a successful status",
  432. "pending": "search pull requests with a pending status",
  433. "failed": "search pull requests with a failed status"
  434. },
  435. "team": {
  436. "": "search issues or pull requests mentioning an organization team",
  437. "jekyll/owners": 'search issues or pull requests for team "@jekyll/owners"',
  438. "myorg/ops": 'search issues or pull requests for team "@myorg/ops"'
  439. },
  440. "topic": {
  441. "": "search repos with the specified topic",
  442. "jekyll": 'search for repos classified with a "jekyll" topic'
  443. },
  444. "topics": {
  445. "": "search repos with greater, less, or a range of topics",
  446. "3": "search repos with exactly 3 topics",
  447. ">3": "search repos with more than three topics",
  448. ">=3": "search repos with three or more topics",
  449. "<3": "search repos with less than 3 topics",
  450. "<=2": "search repos with zero to two topics"
  451. },
  452. // Commits
  453. "tree": {
  454. "": "searches commits referring to the specified tree hash",
  455. "99ca967": "search commits of tree hash"
  456. },
  457. "type": {
  458. "": "search for a user, organization, issue or pull request",
  459. "issue": "only search issues",
  460. "pr": "only search pull requests",
  461. "org": "only search organizations",
  462. "user": "only search personal accounts"
  463. },
  464. // Wiki
  465. "updated": {
  466. "": "search issue & wiki updates before or after a date (no range)",
  467. ">${year}-01-31": "search repos pushed to after Jan 31, ${year}",
  468. ">=${year}-01-31": "search repos pushed to since Jan 31, ${year}",
  469. "<${year}-02-01": "pushed to before Feb ${year}",
  470. "<=${year}-02-01": "pushed to before and including Feb 1, ${year}"
  471. },
  472. // User
  473. "user": {
  474. "": "search for a specific user or organization",
  475. "github": "search in github organization repos"
  476. },
  477. "-user": {
  478. "": "search excludes a specific user or organization",
  479. "github": "search does not include github organization repos"
  480. }
  481. },
  482. // array containing items that should not include a trailing colon
  483. noTrailingColon = [
  484. "AND",
  485. "OR",
  486. "NOT"
  487. ],
  488. list = Object.keys(filters);
  489.  
  490. function updateYear(string) {
  491. return string.replace(/(\$\{year(-1)?\})/g, function(str) {
  492. return {
  493. "${year}": year,
  494. "${year-1}": year - 1
  495. }[str];
  496. });
  497. }
  498.  
  499. // copied from atwho.js DEFAULT_CALLBACKS.highlighter
  500. // https://github.com/ichord/At.js/blob/master/dist/js/jquery.atwho.js#L105
  501. // to add a class to the <strong> html
  502. function highlighter(li, query) {
  503. if (!query) {
  504. return li;
  505. }
  506. const regexp = new RegExp(
  507. ">\\s*([^\<]*?)(" + query.replace("+", "\\+") + ")([^\<]*)\\s*<", "ig"
  508. );
  509. return li.replace(regexp, function(str, $1, $2, $3) {
  510. return `>${$1}<strong class="text-emphasized">${$2}</strong>${$3} <`;
  511. });
  512. }
  513.  
  514. function escapeHTML(string) {
  515. return updateYear(string).replace(/[<>"&]/g, function(str) {
  516. return {
  517. "<" : "&lt;",
  518. ">" : "&gt;",
  519. '"' : "&quot;",
  520. "&" : "&amp;"
  521. }[str];
  522. });
  523. }
  524.  
  525. function addAtJs() {
  526. const $selectors = $(selectors);
  527.  
  528. // add "?" to open list of filters
  529. $selectors.atwho({
  530. at: "?",
  531. data: list,
  532. insertTpl: "${name}",
  533. // show everything in dropdown
  534. limit: list.length,
  535. suffix: "",
  536. callbacks: {
  537. highlighter: highlighter,
  538. beforeInsert: function(value) {
  539. // add colon suffix, as needed
  540. return value + (noTrailingColon.includes(value) ? " " : ":");
  541. }
  542. },
  543. });
  544.  
  545. // Add specific filter examples
  546. list.forEach(label => {
  547. $selectors.atwho({
  548. at: label + (noTrailingColon.includes(label) ? " " : ":"),
  549. data: data[label],
  550. limit: 20,
  551. startWithSpace: false,
  552. callbacks: {
  553. highlighter: highlighter,
  554. tplEval: function(tpl, map) {
  555. // look for default displayTpl = "<li>${name}</li>"
  556. if (tpl.indexOf("<li>") > -1) {
  557. // menu template; text-emphasized needed for GitHub-Dark userstyle
  558. return `
  559. <li class="navigation-item">
  560. <strong class="ghsa-key text-emphasized">
  561. ${escapeHTML(map.name)}
  562. </strong>
  563. <small>${escapeHTML(map.description)}</small>
  564. </li>`;
  565. }
  566. // insert text template
  567. return `${map["atwho-at"]}${updateYear(map.name)}`;
  568. },
  569. sorter: function(query, items) {
  570. // reset suffix setting
  571. this.setting.suffix = " ";
  572. return items;
  573. },
  574. beforeInsert: function(value) {
  575. // don't add a space if the user chooses an empty string value
  576. // meaning the filter ends with a colon, e.g. "in:"
  577. this.setting.suffix = value.slice(-1) === ":" ? "" : " ";
  578. return value;
  579. }
  580. }
  581. });
  582. });
  583. // use classes from GitHub-Dark to make theme match GitHub-Dark
  584. document.querySelectorAll(".atwho-view").forEach(el => {
  585. el.classList.add(...["jump-to-suggestions-results-container", "Box"]);
  586. });
  587. }
  588.  
  589. // prevent reinitializing if user clicks in the input multiple times
  590. function init() {
  591. // build data for At.js
  592. let array;
  593. list.forEach(label => {
  594. array = [];
  595. Object.keys(filters[label]).forEach(key => {
  596. array.push({
  597. "name": key,
  598. "description": filters[label][key]
  599. });
  600. });
  601. // sort empty string to top
  602. data[label] = array.sort((a, b) => {
  603. if (a.name === "") {
  604. return -1;
  605. }
  606. return a.name > b.name ? 1 : -1;
  607. });
  608. });
  609.  
  610. document.querySelector("body").addEventListener("click", event => {
  611. const target = event.target;
  612. if (
  613. target.nodeName === "INPUT" &&
  614. target.matches(selectors)
  615. ) {
  616. $(selectors).atwho("destroy");
  617. addAtJs();
  618. }
  619. });
  620. // remove At.js before the page refreshes
  621. document.querySelector("body").addEventListener("pjax:start", event => {
  622. const target = event.target;
  623. if (target.nodeName === "INPUT" && target.matches(selectors)) {
  624. $(selectors).atwho("destroy");
  625. }
  626. });
  627. }
  628.  
  629. GM_addStyle(`
  630. .atwho-view { position:absolute; top:0; left:0; display:none;
  631. margin-top:18px; border:1px solid #ddd; border-radius:3px;
  632. box-shadow:0 0 5px rgba(0,0,0,0.1); max-height:225px; min-width:300px;
  633. max-width:none !important; overflow: auto; z-index: 11110 !important; }
  634. .atwho-view .cur { background:#36F; color:#fff; }
  635. .atwho-view .cur small { color:#fff; }
  636. .atwho-view strong { color:#36F; }
  637. .atwho-view .cur strong { color:#fff; font:bold; }
  638. .atwho-view ul { list-style:none; padding:0; margin:auto; max-height: 200px;
  639. overflow-y:auto; }
  640. .atwho-view ul li { display:block; padding:5px 10px;
  641. border-bottom: 1px solid #ddd; cursor:pointer; text-align:right; }
  642. .atwho-view small { font-size:smaller; color:#777; font-weight:normal; }
  643. .atwho-view .ghsa-key { font-style:normal; float:left; margin-right:10px; }`
  644. );
  645.  
  646. init();
  647.  
  648. })(jQuery.noConflict(true));