穿越广播转发里世界

Add link to post inner space

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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);
  });

})();