/* globals jQuery, $, waitForKeyElements */ // ==UserScript== // @name 小红书网页爬取id和标题 // @version 0.1 // @namespace http://tampermonkey.net/ // @description xiaohongshuBurst // @author OrlosZiming // @match http*://www.xiaohongshu.com/explore* // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== // @grant none // @require http://code.jquery.com/jquery-3.x-git.min.js // @license MIT // @downloadURL none // ==/UserScript== (function() { 'use strict'; window.onload = function() { // 设置通用IP地址前缀 var articleUrl = "https://www.xiaohongshu.com"; // 获取作者名及跳转连接 var authorNameHref = articleUrl + $("a.name:first").attr("href"); var authorNameText = $("a.name:first").text(); var intervalId; var articleData = {}; // 存储多个标题和链接的对象 // 自动下拉页面 var scrollHeight = document.body.scrollHeight; var currentScroll = 0; var scrollStep = 1000; // 每次滚动的步长 var scrollInterval = 1000; // 每次滚动的时间间隔 function autoScroll() { console.log("down!"+currentScroll) window.scrollTo(0, currentScroll); currentScroll += scrollStep; } // 开始自动下拉 function getArticleInfo() { // 获取笔记时间 var articleDate = $("div.date").text(); articleDate = articleDate.replace(/-/g,'/'); // 遍历每个文章元素 $(".title").each(function(index, element) { // 获取笔记标题 var articleTitle = $(element).text(); // 获取笔记链接 var articleLink = $(element).attr("href"); // 获取文章ID var articleId = articleLink.split("/").pop(); // 将标题和链接存储到对象中 articleData[articleId] = articleTitle; // 输出当前标题和链接的键值对到控制台 console.log(articleId + ": " + articleTitle); // 将当前标题和链接的键值对添加到新窗口的内容中 $(myWindow.document.body).append('