Add link to post inner space
// ==UserScript==
// @name 穿越广播转发里世界
// @namespace https://www.douban.com/people/MoNoMilky/
// @version 0.3
// @description Add link to post inner space
// @match https://www.douban.com/*
// @icon https://www.google.com/s2/favicons?domain=douban.com
// @author Bambooom
// @grant none
// @license MIT
// ==/UserScript==
(function() {
'use strict';
// both self & others
var posts = document.querySelectorAll('.status-wrapper > .reshared_by');
Array.from(posts).map(po => {
var prefix = po.querySelector('a').href;
var id = po.nextElementSibling.getAttribute('data-reshare-id'); // self
if (!id) { // others
var comment = po.parentElement.nextSibling.nextSibling; // comment like 3649983909, say.html, reshared
id = comment.nodeValue.trim().split(',')[0];
}
var link = document.createElement('a');
link.textContent = '里世界';
link.href = prefix + 'status/' + id;
link.target = '_blank';
link.style = 'margin-left: 10px;';
po.insertBefore(link, null);
});
})();