穿越广播转发里世界

Add link to post inner space

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==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);
  });

})();