匹配范围
*://www.uisdc.com/*uisdc-design-news用途 读取优设读报页面中的公开设计资讯,返回标题、摘要、链接、日期文本和标签。适合快速提取读报列表中的最新设计行业资讯。 执行前提 先打开 https://www.uisdc.com/news。脚本优先读取页面中的 .dubao-item,并解析其中的 .dubao-title、.dubao-content、链接和日期信息;如果该结构不可用,会退回到页面内…
*://www.uisdc.com/*dom.read1return await (() => {2 const input = typeof params === "object" && params !== null ? params : {};3 const rawLimit = input.limit === undefined ? 10 : Number(input.limit);4 5 if (!Number.isFinite(rawLimit) || rawLimit <= 0) {6 throw new Error("params.limit must be a positive number.");7 }8 9 const limit = Math.min(Math.floor(rawLimit), 50);10 const cleanText = (value) =>11 String(value || "")12 .replace(/\s+/g, " ")13 .replace(/\u00a0/g, " ")14 .trim();15 16 const absoluteUrl = (value) => {17 if (!value) return null;18 try {19 return new URL(value, window.location.href).href;20 } catch (error) {21 return null;22 }23 };24 25 const itemMap = new Map();26 const addItem = (item) => {27 const key = item.url || `${item.title}:${item.summary}`;28 if (!item.title || itemMap.has(key)) return;29 itemMap.set(key, item);30 };31 32 const nodes = Array.from(document.querySelectorAll(".dubao-item"));33 34 for (const node of nodes) {35 if (itemMap.size >= limit) break;36 37 const titleNode =38 node.querySelector(".dubao-title") ||39 node.querySelector("[class*='title']") ||40 node.querySelector("h1,h2,h3,h4,a[href]");41 const contentNode =42 node.querySelector(".dubao-content") ||43 node.querySelector("[class*='content']") ||44 node.querySelector("p");45 const linkNode = node.querySelector("a[href]");46 const url = absoluteUrl(linkNode?.getAttribute("href")) || window.location.href;47 const dateNode = node.querySelector("time,[class*='date'],[class*='time']");48 const tagNode = node.querySelector("[class*='tag'],[class*='cat']");49 50 addItem({51 title: cleanText(titleNode?.textContent || linkNode?.textContent),52 summary: cleanText(contentNode?.textContent) || null,53 url,54 dateText: cleanText(dateNode?.textContent) || null,55 tag: cleanText(tagNode?.textContent) || null,56 source: "dubao-item",57 });58 }59 60 if (itemMap.size < limit) {61 for (const link of Array.from(document.querySelectorAll('a[href]'))) {62 if (itemMap.size >= limit) break;63 64 const url = absoluteUrl(link.getAttribute("href"));65 const title = cleanText(link.getAttribute("title") || link.textContent);66 67 if (!url || !title || title.length < 4) continue;68 if (!url.includes("uisdc.com")) continue;69 70 const container = link.closest("article,li,section,div") || link;71 const summary = Array.from(container.querySelectorAll("p"))72 .map((node) => cleanText(node.textContent))73 .find((text) => text && text !== title);74 75 addItem({76 title,77 summary: summary || null,78 url,79 dateText: cleanText(container.querySelector("time")?.textContent) || null,80 tag: null,81 source: "link-fallback",82 });83 }84 }85 86 const items = Array.from(itemMap.values()).slice(0, limit);87 88 return {89 limit,90 count: items.length,91 items,92 pageTitle: cleanText(document.title) || null,93 sourceUrl: window.location.href,94 };95})();