{"size": 1210, "ext": "js", "max_stars_repo_path": "src/site-dom/quick-search.js", "max_stars_repo_name": "sabersalv/easy-upload", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/site-dom/quick-search.js", "max_issues_repo_name": "sabersalv/easy-upload", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/site-dom/quick-search.js", "max_forks_repo_name": "sabersalv/easy-upload", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 30.25, "max_line_length": 124, "alphanum_fraction": 0.6165289256}
import {
  CURRENT_SITE_INFO, CURRENT_SITE_NAME,
} from '../const';
import { getUrlParam } from '../common';
const filterBluTorrent = (imdb = '', name = '') => {
  if (imdb) {
    $('#imdb').val(imdb);
  } else if (name) {
    $('#search').val(name);
  }
  const token = $('meta[name="csrf_token"]').attr('content');
  GM_xmlhttpRequest({
    method: 'GET',
    url: `${CURRENT_SITE_INFO.url}/torrents/filter?search=${name}&imdb=${imdb}&_token=${token}&sorting=size&direction=desc`,
    onload (res) {
      $('#facetedSearch').html(res.responseText);
    },
  });
};
// 某些站点需要将IMDB填入检索表单
const fillSearchImdb = () => {
  const imdbParam = getUrlParam('imdb');
  const nameParam = getUrlParam('name');
  const searchType = getUrlParam('search_area');
  if (imdbParam || nameParam) {
    if (CURRENT_SITE_INFO.siteType === 'UNIT3D') {
      filterBluTorrent(imdbParam, nameParam);
    } else if (CURRENT_SITE_NAME === 'Bdc') {
      $('#tsstac').val(imdbParam);
      $('#search_type').val(searchType);
    } else if (CURRENT_SITE_NAME === 'HDAI') {
      $('input[name="keyword"]').val(imdbParam || nameParam);
      $('select[name="keyword_area"]').val(searchType);
    }
  }
};
export {
  fillSearchImdb,
};
