URL Based Search for Some Websites

If you enter required parameter in URL, it trigger a search on website. (URL example: https://subscene.com/subtitles/title?q=Avatar).

目前為 2021-05-31 提交的版本,檢視 最新版本

此腳本不應該直接安裝,它是一個供其他腳本使用的函式庫。欲使用本函式庫,請在腳本 metadata 寫上: // @require https://update.gf.qytechs.cn/scripts/427315/936408/URL%20Based%20Search%20for%20Some%20Websites.js

// ==UserScript==
// @name         URL Based Search for Some Websites
// @version      1.0
// @description  If you enter required parameter in URL, it trigger a search on website. (URL example: https://subscene.com/subtitles/title?q=Avatar).
// @author       nht.ctn
// @namespace    https://github.com/nhtctn
// @include      *://turktorrent.us/?p=torrents&pid=10&q=*
// @include      *://subscene.com/subtitles/title?q=*
// @grant        none
// @run-at       document-start
// @icon         https://turktorrent.us/favicon.ico?lv=2.2
// ==/UserScript==
const pageUrl = window.location.href;
if (pageUrl.search(/https?:\/\/turktorrent\.us/) >= 0) {

	let urlParams = new URLSearchParams(window.location.search);
	let postKeyword = urlParams.get('q');
	let postUrl = 'https://turktorrent.us/?p=torrents&pid=10';

	if (urlParams.get('q') && postKeyword !== '') {
		let postForm = document.createElement("form");
		postForm.setAttribute("method", "post");
		postForm.setAttribute("action", postUrl);
		let hiddenField = document.createElement("input");
		hiddenField.setAttribute("name", "keywords");
		hiddenField.setAttribute("value", postKeyword);
		hiddenField.setAttribute("type", "hidden");
		postForm.appendChild(hiddenField);
		let hiddenSelect = document.createElement("select");
		hiddenSelect.setAttribute("name", "search_type");
		let hiddenOpt = document.createElement("option");
		hiddenOpt.setAttribute("value", "name");
		hiddenSelect.appendChild(hiddenOpt);
		postForm.appendChild(hiddenSelect);
		console.log(postForm);
		document.getElementsByTagName('html')[0].appendChild(postForm);
		postForm.submit();
	}
	else {
		document.location = 'https://turktorrent.us/?p=torrents&pid=10';
	}
}
else if (pageUrl.search(/https?:\/\/subscene\.com/) >= 0) {
	window.stop();

	let urlParams = new URLSearchParams(window.location.search);
	let postKeyword = urlParams.get('q');
	let postUrl = '/subtitles/searchbytitle';

	if (urlParams.get('q') && postKeyword !== '') {
		let postForm = document.createElement("form");
		postForm.setAttribute("method", "post");
		postForm.setAttribute("action", postUrl);
		let hiddenField = document.createElement("input");
		hiddenField.setAttribute("name", "query");
		hiddenField.setAttribute("value", postKeyword);
		hiddenField.setAttribute("type", "hidden");
		postForm.appendChild(hiddenField);
		document.getElementsByTagName('html')[0].appendChild(postForm);
		postForm.submit();
	}
	else {

		document.location = 'https://subscene.com/subtitles';
	}
}

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址