Greasy Fork

来自缓存

Greasy Fork is available in English.

FR:ES - Viewer

Show all QCs in TaoBao and Yupoo

当前为 2021-05-24 提交的版本,查看 最新版本

// ==UserScript==
// @name        FR:ES - Viewer
// @namespace   https://www.reddit.com/user/RobotOilInc
// @author      RobotOilInc
// @version     1.0.0
// @description Show all QCs in TaoBao and Yupoo
// @include     /^https?:\/\/((?:item|2)\.taobao|detail\.tmall)\.com\/(item|meal_detail)\.(htm|html)\?/
// @include     /^https?:\/\/world.(?:taobao|tmall).com/item/\d+.htm/
// @include     /^https?:\/\/world.(?:taobao|tmall).com/item/\d+.html/
// @include     /^https?:\/\/.*\.x\.yupoo\.com\/albums\/\d+/
// @connect     self
// @connect     127.0.0.1
// @connect     localhost
// @require     https://code.jquery.com/jquery-3.4.1.min.js
// @require     https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/4.3.1/iframeResizer.min.js
// @run-at      document-end
// ==/UserScript==
'use strict';

/* jshint esversion: 8 */
/* globals $:false */

const _version = "0.1.0";
const _url = "https://localhost:8000/";

(async function () {
	const searchParams = new URLSearchParams(window.location.search);
	const $iframe = $('<iframe id="qciframe" style="border:0" />')
	$iframe.on('load',function () {
		$iframe.iFrameResize({bodyMargin: 10, bodyPadding: 10});
	});

	// Are we on a Yupoo album?
	if (window.location.hostname.includes('yupoo.com')) {
		const website = 'yupoo',
			id = window.location.href.match(/^https?:\/\/.*\.x\.yupoo\.com\/albums\/(\d+)/)[1],
			author = window.location.hostname.replace(".x.yupoo.com", '')

		$(".showalbum__imagecardwrap").append($iframe);
		$iframe.attr('src', _url + 'view/qc/' + website + '/' + id + '/' + author);

		return;
	}

	// Are we on a Taobao/Tmall item page?
	if (window.location.hostname.includes('taobao') || window.location.hostname.includes('tmall')) {
		$("#description").prepend($iframe);
		$iframe.attr('src', _url + 'qcdb/qcview.php?id=' + searchParams.get("id"));
		$iframe.css("width", "770px");

		return;
	}

	console.debug("Unsupported website/missing if statement");
})();