Skip to content

Commit

Permalink
fix: fix issue for jquery on dev
Browse files Browse the repository at this point in the history
  • Loading branch information
techmovie committed Dec 9, 2024
1 parent 8a4fe73 commit 985523b
Show file tree
Hide file tree
Showing 54 changed files with 75 additions and 18 deletions.
3 changes: 1 addition & 2 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export default [{
languageOptions: {
globals: {
...globals.browser,
...globals.jquery,
...globals.greasemonkey,
},

Expand All @@ -64,7 +63,7 @@ export default [{
rules: {
'no-use-before-define': 0,
semi: ['error', 'always'],
'no-undef': 'off',
'no-undef': 0,
'comma-dangle': ['error', 'always-multiline'],
indent: 'off',
'@stylistic/ts/indent': ['error', 2],
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"@jsdevtools/version-bump-prompt": "^6.1.0",
"@preact/preset-vite": "^2.9.1",
"@stylistic/eslint-plugin-ts": "^2.9.0",
"@types/jquery": "^3.5.31",
"@types/jquery": "^3.5.32",
"@types/parse-torrent": "^5.8.7",
"@types/tampermonkey": "^4.0.5",
"@typescript-eslint/eslint-plugin": "^8.8.0",
Expand Down
1 change: 1 addition & 0 deletions src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
} from './const';
import i18nConfig from './i18n.json';
import { toast } from 'sonner';
import $ from 'jquery';
interface RequestOptions {
method?: 'GET' | 'POST'
responseType?: 'json' | 'blob' | 'arraybuffer' | undefined
Expand Down
1 change: 1 addition & 0 deletions src/components/Container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import SettingPanel from './SettingPanel';
import ConfigSvg from '../assets/setting.svg';
import { getQuickSearchUrl } from './common';
import { Toaster } from 'sonner';
import $ from 'jquery';

const Container = () => {
const [settingPanelOpen, setSettingPanelOpen] = useState(false);
Expand Down
1 change: 1 addition & 0 deletions src/components/Douban.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
getSubTitle, getAreaCode, getPreciseCategory,
} from '../common';
import { toast } from 'sonner';
import $ from 'jquery';

const getTvSeasonData = async (data:Douban.Season) => {
const { title: torrentTitle } = TORRENT_INFO;
Expand Down
2 changes: 2 additions & 0 deletions src/components/SearchList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {
getValue, $t,
} from '../common';
import { getQuickSearchUrl } from './common';
import $ from 'jquery';

type SiteName = keyof typeof PT_SITE
const SearchList = () => {
const handleSearchClickEvent = (siteName:SiteName) => {
Expand Down
2 changes: 0 additions & 2 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import './style.css';
import App from './components/Container';
import $ from 'jquery';

window.jQuery = $;

const torrentInfoMatchArray = location.hash && location.hash.match(/(^|#)torrentInfo=([^#]*)(#|$)/);
const timestampMatchArray = location.hash && location.hash.match(/(^|#)timestamp=([^#]*)(#|$)/);
const torrentTimestamp = (timestampMatchArray && timestampMatchArray.length > 0) ? timestampMatchArray[2] : null;
Expand Down
1 change: 1 addition & 0 deletions src/site-dom/ptpimg.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { render } from 'preact';
import { toast } from 'sonner';
import $ from 'jquery';

if (location.host === 'ptpimg.me') {
const ptpImgApiKey = GM_getValue('easy-seed.ptp-img-api-key') || '';
Expand Down
2 changes: 2 additions & 0 deletions src/site-dom/quick-search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import {
CURRENT_SITE_INFO, CURRENT_SITE_NAME,
} from '../const';
import { getUrlParam, fetch } from '../common';
import $ from 'jquery';

const filterBluTorrent = (imdb = '', name = '') => {
if (imdb) {
$('#imdb').val(imdb);
Expand Down
1 change: 1 addition & 0 deletions src/source/avistaz.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
getInfoFromBDInfo, getSize, getFilterBBCode,
getPreciseCategory, getSourceFromTitle, getTagsFromSubtitle, getScreenshotsFromBBCode,
} from '../common';
import $ from 'jquery';
interface BasicInfo {
Type: string,
'File Size':string,
Expand Down
2 changes: 2 additions & 0 deletions src/source/bdc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {
getBDInfoOrMediaInfo, getScreenshotsFromBBCode, getTagsFromSubtitle,
getAreaCode,
} from '../common';
import $ from 'jquery';

export default async () => {
const torrentInfo = await getTorrentInfo();
TORRENT_INFO.sourceSite = CURRENT_SITE_NAME;
Expand Down
1 change: 1 addition & 0 deletions src/source/bhd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
getInfoFromBDInfo, getSize, getFilterBBCode,
getTagsFromSubtitle, getPreciseCategory, getScreenshotsFromBBCode,
} from '../common';
import $ from 'jquery';

export default async () => {
TORRENT_INFO.sourceSite = CURRENT_SITE_NAME;
Expand Down
1 change: 1 addition & 0 deletions src/source/btn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
getBDInfoOrMediaInfo, getSize,
getFilterBBCode, fetch, getSourceFromTitle,
} from '../common';
import $ from 'jquery';

export default async () => {
const torrentId = getUrlParam('torrentid');
Expand Down
1 change: 1 addition & 0 deletions src/source/emp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { CURRENT_SITE_NAME, CURRENT_SITE_INFO, TORRENT_INFO } from '../const';
import {
getUrlParam, getFilterBBCode,
} from '../common';
import $ from 'jquery';

export default async () => {
const torrentId = getUrlParam('id');
Expand Down
1 change: 1 addition & 0 deletions src/source/gazelle-music.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getUrlParam, fetch, htmlToBBCode } from '../common';
import { CURRENT_SITE_INFO, TORRENT_INFO, CURRENT_SITE_NAME } from '../const';
import DOMPurify from 'dompurify';
import $ from 'jquery';

export default async () => {
const torrentId = getUrlParam('torrentid');
Expand Down
1 change: 1 addition & 0 deletions src/source/gpw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
getInfoFromMediaInfo, getInfoFromBDInfo,
fetch,
} from '../common';
import $ from 'jquery';

export default async () => {
const torrentId = getUrlParam('torrentid');
Expand Down
1 change: 1 addition & 0 deletions src/source/hdb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
getFilterBBCode, getBDInfoOrMediaInfo, fetch,
getTagsFromSubtitle, getPreciseCategory, getScreenshotsFromBBCode,
} from '../common';
import $ from 'jquery';

export default async () => {
const torrentId = getUrlParam('id');
Expand Down
1 change: 1 addition & 0 deletions src/source/hdspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
getBDInfoOrMediaInfo, getAudioCodecFromTitle, getSize, getVideoCodecFromTitle, getFilterBBCode,
getSourceFromTitle, getTagsFromSubtitle, getPreciseCategory, getScreenshotsFromBBCode, fetch,
} from '../common';
import $ from 'jquery';

export default async () => {
const { Name, Category, Size, Description } = getBasicInfo();
Expand Down
1 change: 1 addition & 0 deletions src/source/hdt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
getBDInfoOrMediaInfo, getAudioCodecFromTitle, getSize, getVideoCodecFromTitle, getFilterBBCode,
getSourceFromTitle, getTagsFromSubtitle, getPreciseCategory, getScreenshotsFromBBCode,
} from '../common';
import $ from 'jquery';

export default async () => {
const title = document.title.replace(/HD-Torrents.org\s*-/ig, '').trim();
Expand Down
1 change: 1 addition & 0 deletions src/source/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { fetch, $t } from '../common';
import { Buffer } from 'buffer/index.js';
import { CURRENT_SITE_INFO } from '../const';
import { toast } from 'sonner';
import $ from 'jquery';

/**
* 格式化视频类型
Expand Down
1 change: 1 addition & 0 deletions src/source/hh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
getSourceFromTitle, getAreaCode, getDoubanInfo,
} from '../common';
import { getVideoType, getCategory } from './helper';
import $ from 'jquery';

export default async () => {
const title = formatTorrentTitle(document.title.match(/"(.+)"/)?.[1] || '');
Expand Down
5 changes: 3 additions & 2 deletions src/source/kg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
getBDInfoOrMediaInfo, getAudioCodecFromTitle, getVideoCodecFromTitle, getFilterBBCode,
getTagsFromSubtitle, getPreciseCategory, getScreenshotsFromBBCode,
} from '../common';
import $ from 'jquery';
interface BasicInfo {
[key:string]:string
}
Expand All @@ -19,9 +20,9 @@ export default async () => {
const title = formatTorrentTitle(fileName || torrentFileName);
const imdbUrl = InternetLink?.match(/imdb/) ? InternetLink : '';
const movieTitles = $('.outer h1').text().split('- ');
let movieName, movieAkaName;
let movieName = ''; let movieAkaName = '';
if (movieTitles.length >= 2) {
[movieName, movieAkaName = ''] = movieTitles[1].replace(/\(\d+\)/, '').trim().split(/AKA/i);
[movieName, movieAkaName] = movieTitles[1].replace(/\(\d+\)/, '').trim().split(/AKA/i);
}
const country = $('.outer h1 img').attr('alt') || '';
const year = Year;
Expand Down
1 change: 1 addition & 0 deletions src/source/mtv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
getSize, getFilterBBCode, getSourceFromTitle, getScreenshotsFromBBCode,
getVideoCodecFromTitle, getAudioCodecFromTitle, getTagsFromSubtitle,
} from '../common';
import $ from 'jquery';

export default async () => {
const torrentId = getUrlParam('torrentid');
Expand Down
1 change: 1 addition & 0 deletions src/source/nexusphp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
getAudioCodecFromTitle, getVideoCodecFromTitle, getBDInfoOrMediaInfo, getPreciseCategory,
} from '../common';
import { getVideoType, getCategory, getResolution, getFormat } from './helper';
import $ from 'jquery';

/**
* 获取 NexusPHP 默认数据
Expand Down
1 change: 1 addition & 0 deletions src/source/ptp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
getInfoFromMediaInfo, getInfoFromBDInfo,
replaceRegSymbols, fetch,
} from '../common';
import $ from 'jquery';

export default async () => {
const torrentId = getUrlParam('torrentid');
Expand Down
1 change: 1 addition & 0 deletions src/source/speedapp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
getFilterBBCode, getSourceFromTitle, getScreenshotsFromBBCode,
getVideoCodecFromTitle, getAudioCodecFromTitle, getTagsFromSubtitle,
} from '../common';
import $ from 'jquery';

export default async () => {
TORRENT_INFO.sourceSite = CURRENT_SITE_NAME;
Expand Down
2 changes: 2 additions & 0 deletions src/source/teamhd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {
getPreciseCategory, getSourceFromTitle,
getTagsFromSubtitle, getScreenshotsFromBBCode,
} from '../common';
import $ from 'jquery';

export default async () => {
const torrentInfo = await getTorrentInfo();
torrentInfo.category = getPreciseCategory(torrentInfo, torrentInfo.category);
Expand Down
1 change: 1 addition & 0 deletions src/source/tik.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
getInfoFromBDInfo,
getSourceFromTitle,
} from '../common';
import $ from 'jquery';

export default async () => {
// const torrentId = getUrlParam('id');
Expand Down
1 change: 1 addition & 0 deletions src/source/ttg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
getAreaCode, getTagsFromSubtitle, getAudioCodecFromTitle,
getVideoCodecFromTitle, getPreciseCategory, getBDInfoOrMediaInfo,
} from '../common';
import $ from 'jquery';

export default async () => {
TORRENT_INFO.sourceSite = CURRENT_SITE_NAME;
Expand Down
1 change: 1 addition & 0 deletions src/source/uhd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
getTagsFromSubtitle, getPreciseCategory, getScreenshotsFromBBCode,
getUrlParam, getSize, getSourceFromTitle, fetch,
} from '../common';
import $ from 'jquery';

export default async () => {
const torrentId = getUrlParam('torrentid');
Expand Down
2 changes: 2 additions & 0 deletions src/source/unit3d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {
getFilterBBCode,
getTagsFromSubtitle, getPreciseCategory, getScreenshotsFromBBCode,
} from '../common';
import $ from 'jquery';

interface BasicInfo {
Category: string
Name:string
Expand Down
1 change: 1 addition & 0 deletions src/target/autofill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
getDoubanInfo, getSubTitle,
} from '../common';
import { toast } from 'sonner';
import $ from 'jquery';

async function autoFillDoubanInfo (selfDom: JQuery, info: TorrentInfo.Info) {
try {
Expand Down
2 changes: 2 additions & 0 deletions src/target/bdc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {
} from '../common';
import { PT_SITE } from '../const';
import { getScreenshotsBBCode, getTeamName } from './common';
import $ from 'jquery';

const currentSiteInfo = PT_SITE.Bdc;

export default async (info:TorrentInfo.Info) => {
Expand Down
1 change: 1 addition & 0 deletions src/target/bhd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
import {
matchSelectForm, buildPTPDescription, isChineseTacker, filterNexusDescription,
} from './common';
import $ from 'jquery';

const currentSiteInfo = PT_SITE.BeyondHD;

Expand Down
2 changes: 2 additions & 0 deletions src/target/bib.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import $ from 'jquery';

export default (info:TorrentInfo.Info) => {
if (!info.doubanBookInfo) {
return;
Expand Down
2 changes: 2 additions & 0 deletions src/target/byr.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { PT_SITE } from '../const';
import { getInfoFromMediaInfo, getInfoFromBDInfo } from '../common';
import $ from 'jquery';

export default (info:TorrentInfo.Info) => {
const currentSiteInfo = PT_SITE.BYR;
const {
Expand Down
1 change: 1 addition & 0 deletions src/target/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
getFilterImages,
} from '../common';
import { CURRENT_SITE_NAME } from '../const';
import $ from 'jquery';

const getScreenshotsBBCode = (imgArray:string[]) => {
return imgArray.map(img => {
Expand Down
1 change: 1 addition & 0 deletions src/target/gazelle-music.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { base64ToBlob } from './common';
import { Buffer } from 'buffer/index';
import { CURRENT_SITE_INFO, CURRENT_SITE_NAME } from '../const';
import { getUrlParam, fetch } from '../common';
import $ from 'jquery';

export default async (info:TorrentInfo.Info) => {
const { musicJson } = info;
Expand Down
1 change: 1 addition & 0 deletions src/target/gpw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
getUrlParam, getInfoFromMediaInfo,
} from '../common';
import { buildPTPDescription } from './common';
import $ from 'jquery';

const currentSiteInfo = PT_SITE.GPW;
export default async (info:TorrentInfo.Info) => {
Expand Down
2 changes: 2 additions & 0 deletions src/target/hdr.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import $ from 'jquery';

export default (info:TorrentInfo.Info) => {
const { description, doubanInfo } = info;
const fullDescription = description + doubanInfo;
Expand Down
1 change: 1 addition & 0 deletions src/target/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
base64ToBlob,
} from './common';
import { SITE_OPERATIONS } from './site-operations';
import $ from 'jquery';

type SelectKey = 'videoCodec' | 'videoType' | 'resolution' | 'source' | 'area'

Expand Down
1 change: 1 addition & 0 deletions src/target/its.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
$t,
} from '../common';
import { getTeamName, getScreenshotsBBCode } from './common';
import $ from 'jquery';

export default async (info:TorrentInfo.Info) => {
let template = `[center]
Expand Down
1 change: 1 addition & 0 deletions src/target/kg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
getBDType,
} from '../common';
import { PT_SITE } from '../const';
import $ from 'jquery';

export default async (info:TorrentInfo.Info) => {
const { imdbUrl, screenshots, mediaInfos, resolution, source, videoType } = info;
Expand Down
1 change: 1 addition & 0 deletions src/target/mt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const fillMTInfo = async (info:TorrentInfo.Info) => {
}
});
fillDescription(targetHelper.info.description);
targetHelper.fillTorrentFile();
};

function setInputValue (selector:string, value:string, isCheckbox = false) {
Expand Down
1 change: 1 addition & 0 deletions src/target/npubits.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { PT_SITE } from '../const';
import { getTeamName } from './common';
import $ from 'jquery';

export default (info:TorrentInfo.Info) => {
const currentSiteInfo = PT_SITE.NPUBits;
Expand Down
2 changes: 2 additions & 0 deletions src/target/ptn.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import $ from 'jquery';

export default (info:TorrentInfo.Info) => {
const { resolution, videoType, source } = info;
let format = '';
Expand Down
2 changes: 2 additions & 0 deletions src/target/ptp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { PT_SITE } from '../const';
import {
getUrlParam, getBDType, getInfoFromMediaInfo,
} from '../common';
import $ from 'jquery';

export default async (info:TorrentInfo.Info) => {
const currentSiteInfo = PT_SITE.PTP;
const {
Expand Down
Loading

0 comments on commit 985523b

Please # to comment.