您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Adds post date to instagram feed
当前为
// ==UserScript== // @name Instagram Post Date // @namespace http://tampermonkey.net/ // @version 1.0 // @description Adds post date to instagram feed // @author SH3LL // @match https://www.instagram.com/* // @grant GM_addStyle // ==/UserScript== (function() { 'use strict'; GM_addStyle(` .post-date-label { position: absolute; top: 10px; left: 10px; background-color: rgba(0, 0, 0, 0.7); color: white; padding: 5px; border-radius: 5px; font-size: 12px; z-index: 9999; } `); let interceptedJsons = []; const originalSend = XMLHttpRequest.prototype.send; XMLHttpRequest.prototype.send = function() { this.addEventListener('readystatechange', function() { if (this.readyState === 4 && this.responseURL.includes('/graphql/query')) { try { const json = JSON.parse(this.responseText); if (json && json.data && json.data.xdt_api__v1__feed__user_timeline_graphql_connection) { interceptedJsons.push(json); } } catch (error) { console.error("Errore nel parsing JSON", error); } } }); originalSend.apply(this, arguments); }; function addDateLabel(postElement, date) { if (!postElement.querySelector('.post-date-label')) { const label = document.createElement('div'); label.classList.add('post-date-label'); label.textContent = formatDate(date * 1000); postElement.style.position = 'relative'; postElement.children[0].appendChild(label); } } function formatDate(timestamp) { const date = new Date(timestamp); const options = { year: 'numeric', month: 'long', day: 'numeric' }; return date.toLocaleDateString('en-US', options); } function processPosts() { const postElements = document.querySelectorAll('.x1lliihq.x1n2onr6.xh8yej3.x4gyw5p.x1ntc13c.x9i3mqj.x11i5rnm.x2pgyrj'); postElements.forEach(postElement => { const linkElement = postElement.querySelector('a[href*="/p/"], a[href*="/reel/"]'); if (linkElement) { const href = linkElement.getAttribute('href'); const parts = href.split('/'); const postCode = parts[3]; interceptedJsons.forEach(json => { if (json && json.data && json.data.xdt_api__v1__feed__user_timeline_graphql_connection && json.data.xdt_api__v1__feed__user_timeline_graphql_connection.edges) { json.data.xdt_api__v1__feed__user_timeline_graphql_connection.edges.forEach(edge => { if (edge.node.code === postCode) { const timestamp = edge.node.taken_at; addDateLabel(postElement, timestamp); } }); } }); } }); } processPosts(); const observer = new MutationObserver(mutations => { processPosts(); }); observer.observe(document.body, { childList: true, subtree: true }); })();