Skip to content

Instantly share code, notes, and snippets.

@fanzeyi
Last active August 25, 2017 12:10
Show Gist options
  • Save fanzeyi/c559aa493c22e420f4e15d739e2638a1 to your computer and use it in GitHub Desktop.
Save fanzeyi/c559aa493c22e420f4e15d739e2638a1 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Revert Reshare
// @namespace http://zr.is/
// @version 0.3.1
// @description Make Reshare Great Again!
// @author Zeyi Fan
// @match https://www.douban.com/*
// @grant GM_addStyle
// ==/UserScript==
(function() {
'use strict';
GM_addStyle ( " \
.reshare_author:before { \
content: ''; \
display: inline-block; \
width: 18px; \
height: 14px; \
vertical-align: middle; \
background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB3aWR0aD0iOTVweCIgaGVpZ2h0PSI1MnB4IiB2aWV3Qm94PSIwIDAgOTUgNTIiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+CiAgICA8IS0tIEdlbmVyYXRvcjogU2tldGNoIDQxLjIgKDM1Mzk3KSAtIGh0dHA6Ly93d3cuYm9oZW1pYW5jb2RpbmcuY29tL3NrZXRjaCAtLT4KICAgIDx0aXRsZT5Hcm91cDwvdGl0bGU+CiAgICA8ZGVzYz5DcmVhdGVkIHdpdGggU2tldGNoLjwvZGVzYz4KICAgIDxkZWZzPjwvZGVmcz4KICAgIDxnIGlkPSJQYWdlLTEiIHN0cm9rZT0ibm9uZSIgc3Ryb2tlLXdpZHRoPSIxIiBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPgogICAgICAgIDxnIGlkPSJyZXNoYXJlLWNvcHktY29weSIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoLTE3LjAwMDAwMCwgLTM4LjAwMDAwMCkiIGZpbGw9IiM3MDcwNzAiPgogICAgICAgICAgICA8ZyBpZD0iR3JvdXAiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDE3LjAwMDAwMCwgMzguMDAwMDAwKSI+CiAgICAgICAgICAgICAgICA8cGF0aCBkPSJNODQsNiBMODQsMzUgTDcyLDM1IEw3MiwxMiBMNTMsMTIgTDQxLDAgTDg0LDAgTDg0LDYgWiBNNjAsMzUgTDk1LDM1IEw3Ny41LDUyIEw2MCwzNSBaIiBpZD0iQ29tYmluZWQtU2hhcGUiPjwvcGF0aD4KICAgICAgICAgICAgICAgIDxwYXRoIGQ9Ik00Myw2IEw0MywzNSBMMzEsMzUgTDMxLDEyIEwxMiwxMiBMMCwwIEw0MywwIEw0Myw2IFogTTE5LDM1IEw1NCwzNSBMMzYuNSw1MiBMMTksMzUgWiIgaWQ9IkNvbWJpbmVkLVNoYXBlIiB0cmFuc2Zvcm09InRyYW5zbGF0ZSgyNy4wMDAwMDAsIDI2LjAwMDAwMCkgc2NhbGUoLTEsIC0xKSB0cmFuc2xhdGUoLTI3LjAwMDAwMCwgLTI2LjAwMDAwMCkgIj48L3BhdGg+CiAgICAgICAgICAgIDwvZz4KICAgICAgICA8L2c+CiAgICA8L2c+Cjwvc3ZnPg==); \
background-repeat: no-repeat; \
background-size: 100%; \
background-position: 0px 2px; \
margin-right: 2px; \
} \
.reshare_author { \
color: #7AA680; \
margin-left: 5px; \
")
window.addEventListener('load', function() {
$(".status-reshared-wrapper").each((_, element) => {
var $element = $(element)
var reshare_text = $element.find(".reshared_hd .text blockquote").text()
if (reshare_text.length == 0) {
// no comment, change to old-style reshare
var reshare_author = $element.find(".reshared_hd .lnk-people").text()
var reshare_status = $element.find(".status-real-wrapper .status-item")
var actions = reshare_status.find(".actions")
var delete_button = $element.find("> .status-item .btn-action-reply-delete")
actions.append(`<span class="reshare_author">由${reshare_author}转播</span>`)
if (delete_button.length != 0) {
delete_button.css({"margin-left": "10px"})
actions.append(delete_button)
}
$element.empty()
$element.append(reshare_status)
$element.removeClass("status-reshared-wrapper")
}
})
})
})();
@ushuz
Copy link

ushuz commented Dec 26, 2016

excited

@ushuz
Copy link

ushuz commented Dec 26, 2016

这种没内容的嵌套转播应该也还原成旧样式比较好

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment