// ==UserScript==
// @name 2048增强插件
// @namespace none
// @version 0.4.9
// @description 2048论坛帖子加载预览图和链接,内容独立显示在标题下方,悬浮图片根据宽高比自动缩放,并智能去除翻页时的重复帖子。悬浮标题1.5秒可加载全部图片。新增付费贴检测。
// @author nonono
// @match *://2048.cc/*
// @grant none
// @require https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js
// @license MIT
// @downloadURL https://update.greasyfork.icu/scripts/551438/2048%E5%A2%9E%E5%BC%BA%E6%8F%92%E4%BB%B6.user.js
// @updateURL https://update.greasyfork.icu/scripts/551438/2048%E5%A2%9E%E5%BC%BA%E6%8F%92%E4%BB%B6.meta.js
// ==/UserScript==
(function ($) {
"use strict";
$(function () {
const styles = `
.userscript-content-cell { padding: 5px 0 10px !important; border: none !important; }
.userscript-image-gallery { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 8px; }
.userscript-preview-image { height: 200px; width: auto; cursor: pointer; display: block; transition: opacity 0.2s ease; border-radius: 4px; background-color: #f0f0f0; }
.userscript-preview-image:hover { opacity: 0.8; }
.userscript-link, .userscript-magnet-link { padding: 5px 0; font-size: 12px; font-weight: normal; word-break: break-all; cursor: pointer; }
.userscript-no-content-notice { color: #999; font-size: 12px; padding: 10px 0; }
.userscript-image-count { font-size: 12px; color: #008000; margin-left: 8px; font-weight: normal; }
#userscript-floating-image { display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); width: auto; height: auto; max-width: 95vw; max-height: 95vh; z-index: 99999; border: 5px solid white; box-shadow: 0 10px 30px rgba(0,0,0,0.5); pointer-events: none; border-radius: 5px; }
`;
$("head").append(``);
$("body").append(``);
$(document).on("mouseenter", ".userscript-preview-image", function () {
const $this = $(this);
const imageUrl = $this.attr("src");
const naturalWidth = $this.data("naturalWidth");
const naturalHeight = $this.data("naturalHeight");
if (!imageUrl || !naturalWidth || !naturalHeight) return;
const $floatingImage = $("#userscript-floating-image");
if (naturalWidth > naturalHeight) {
$floatingImage.css({ width: "50vw", height: "auto" });
} else {
$floatingImage.css({ height: "80vh", width: "auto" });
}
$floatingImage.attr("src", imageUrl).stop(true, true).fadeIn(100);
});
$(document).on("mouseleave", ".userscript-preview-image", () => {
$("#userscript-floating-image").stop(true, true).fadeOut(100);
});
const ads = [".promo-container", ".nav-container", ".movie-banner", "#ads"];
$.each(ads, (i, e) => $(e).hide());
function copyToClipboard(text, element) {
navigator.clipboard
.writeText(text)
.then(() => {
if (element) {
const originalText = $(element).text();
$(element).text("已复制!").css("color", "darkred");
setTimeout(() => {
$(element).text(originalText).css("color", "");
}, 1500);
}
})
.catch((err) => console.error("[2048增强插件] 复制失败:", err));
}
if (window.location.href.includes("read.php")) {
const readObserver = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
if (mutation.type === "childList") {
$(mutation.addedNodes)
.find('.f14 a[href*="name="]')
.addBack('.f14 a[href*="name="]')
.each(function () {
const $link = $(this),
href = $link.attr("href");
if (href && href.includes("name=")) {
const st = href.substring(href.indexOf("=") + 1);
$link.attr(
"href",
`https://down.dataaps.com/down.php/${st}.torrent`
);
}
});
}
});
});
readObserver.observe(document.body, { childList: true, subtree: true });
}
const patterns = [".subject", 'th a[href*="tid"]'];
const pattern = patterns.find((p) => $(p).length > 0);
if (pattern) {
function createImageElement(src, container) {
const MIN_IMG_WIDTH = 100;
const MIN_IMG_HEIGHT = 100;
const $previewImg = $('
');
$previewImg
.on("load", function () {
if (
this.naturalWidth < MIN_IMG_WIDTH ||
this.naturalHeight < MIN_IMG_HEIGHT
) {
$(this).remove();
return;
}
$(this).data({
naturalWidth: this.naturalWidth,
naturalHeight: this.naturalHeight,
});
})
.on("error", function () {
$(this).remove();
});
container.append($previewImg);
$previewImg.attr("src", src);
}
function expandAndShowAllImages(linkElement) {
const $linkElement = $(linkElement);
if ($linkElement.data("all-images-expanded")) {
return;
}
const allImageUrls = $linkElement.data("allImageUrls");
const $insertionPoint = $linkElement.closest("tr").length
? $linkElement.closest("tr")
: $linkElement.closest("th, .subject");
const $galleryContainer = $insertionPoint
.next()
.find(".userscript-image-gallery");
if (
allImageUrls &&
allImageUrls.length > 0 &&
$galleryContainer.length > 0
) {
if (allImageUrls.length > $galleryContainer.children("img").length) {
console.log(
`[2048增强插件] 悬浮加载全部 ${allImageUrls.length} 张图片...`
);
$galleryContainer.empty();
allImageUrls.forEach((src) => {
createImageElement(src, $galleryContainer);
});
$linkElement.data("all-images-expanded", true);
}
}
}
function processPostLink(linkElement) {
const $linkElement = $(linkElement);
if ($linkElement.hasClass("userscript-processed")) return;
$linkElement.addClass("userscript-processed");
$.ajax({
url: linkElement.href,
method: "get",
success: function (data) {
const $data = $(data);
const $titleRow = $linkElement.closest("tr");
const $insertionPoint = $titleRow.length
? $titleRow
: $linkElement.closest("th, .subject");
// ===== 新增功能:检测付费内容 =====
const $postContentForCheck = $data.find(".f14");
if ($postContentForCheck.text().includes("本内容需向作者支付")) {
$linkElement.before(
'【付费】'
);
}
// =====================================
const $contentCell = $(
'