Created
March 23, 2018 15:18
-
-
Save chrisliuqq/1991d01f76a9e18987aa1fd1c516320d to your computer and use it in GitHub Desktop.
tieba get content
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name 取得貼罷的內容 | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author You | |
// @match *://tieba.baidu.com/p/*?see_lz=1* | |
// @grant none | |
// ==/UserScript== | |
function append_article() { | |
var divStyle = { | |
position: "fixed", | |
top: "100px", | |
right: "5px", | |
width: "500px", | |
border: "3px solid rgb(0, 0, 0)", | |
background: "#efe", | |
bottom: "10px", | |
overflowY: "auto", | |
wordBreak: "break-word", | |
zIndex: "10000" | |
}; | |
var div = $('<div id="article_sets">').css(divStyle); | |
var s = ""; | |
s = $('h3.core_title_txt').text() + "<br /><br />"; | |
$(".d_post_content").each(function(i, e) { | |
s += $(e).html(); | |
}); | |
s = s.replace(/<br><br><br>/g, "<br><br>"); | |
s = s.replace(/<br><br><br>/g, "<br><br>"); | |
s = s.replace(/<br><br><br>/g, "<br><br>"); | |
s = s.replace(/<br><br><br>/g, "<br><br>"); | |
s = s.replace(/"(.*?)"/g, "「$1」"); | |
s = s.replace(/“(.*?)”/g, "「$1」"); | |
div.html(s); | |
$('body').append(div); | |
SelectText('article_sets'); | |
} | |
function SelectText(element) { | |
var doc = document, | |
text = doc.getElementById(element), | |
range, selection; | |
selection = window.getSelection(); | |
range = document.createRange(); | |
range.selectNodeContents(text); | |
selection.removeAllRanges(); | |
selection.addRange(range); | |
text.focus(); | |
} | |
(function() { | |
'use strict'; | |
// $("<button/>").style({ "position": "fixed", "top": "100px", "left": "5px", "width" : "500px", "height" : "500px", "border" : "3px solid #000" }).text("測試").click(append_article).appendTo('body'); | |
// var btn = $("<button/>").html("test"); | |
// $("body").append(btn); | |
var btnStyle = { | |
position: "fixed", | |
right: "10px", | |
top: "50px", | |
width: "100px", | |
height: "50px" | |
}; | |
var btn = $('<button/>').text('複製').css(btnStyle).click(function() { | |
document.execCommand('copy'); | |
}); | |
$("body").append(btn); | |
//$(".skin_normal .wrap1").css("backgroundColor", "#000"); | |
append_article(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment