Last active
December 12, 2019 04:10
-
-
Save mutoo/e862d189dc3ca9a8c284adffd5b154a8 to your computer and use it in GitHub Desktop.
The wechat reading using canvas to render the text to prevent text copying, but there is a way to bypass it.
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
(()=>{ | |
// hijack the fillText function to collect characters info | |
const c2d = CanvasRenderingContext2D.prototype; | |
const data = []; | |
const oldFillText = c2d.fillText; | |
c2d.fillText = function() { | |
const [char,x,y] = arguments; | |
data.push({ | |
char, | |
x, | |
y | |
}); | |
return oldFillText.apply(this, arguments); | |
} | |
$('.readerContent').__vue__.drawSomeTexts(); | |
console.log(data.sort((a,b)=>{ | |
if (a.y != b.y) { | |
return a.y - b.y | |
} else { | |
return a.x - b.x; | |
} | |
} | |
).map(d=>d.char).join('')); | |
} | |
)(); | |
// Tested on this page: | |
// https://weread.qq.com/web/reader/42632ab05a9bc14cef1d78ak5cb31e021615ed74f14adf2 | |
// Output: | |
// 第十六章 三体、哥白尼、宇宙橄榄球、三日凌空从叶文洁家里出来以后,汪淼心绪难平,这两天的遭遇和红岸的故事,这两件不相干的事纠结在一起,使世界在一夜之间变得异常陌生。回到家后,为了摆脱这种心绪,他打开电脑,穿上V装具,第三次进入《三体》。他的心态调整得很成功,当登录界面出现时,汪淼像换了一个人似的,心中立刻充满了莫名的兴奋。... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
再花点时间看一下,发现文章内容直接存在 vue 组件里 chapterContentHtml
Output: