Created
October 31, 2023 01:36
-
-
Save tianheg/21fe4d63babeedd5f17eed1c1fd7e812 to your computer and use it in GitHub Desktop.
微信阅读复制目录
This file contains 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 微信阅读复制目录 | |
// @description 微信阅读复制目录 | |
// @match https://weread.qq.com/web/reader/* | |
// @grant GM_setClipboard | |
// @version 1.0 | |
// @require https://cdn.jsdelivr.net/npm/jquery@3/dist/jquery.min.js | |
// ==/UserScript== | |
/* global $ */ | |
$(window).on('load', function(){ | |
let btn = '<button class="readerControls_item mdbtn">md</button>' | |
$('.readerControls').append(btn); | |
$('.mdbtn').click(function() { | |
let md_str = ''; | |
let book_title = $('.readerCatalog_bookInfo_title_txt')[0].textContent; | |
md_str += `# ${book_title} [/] \n`; | |
// let book_author = $('.readerCatalog_bookInfo_author:first').textContent; | |
const regex = /level(\d+)/; | |
$('.chapterItem_link').each(function(idx, obj){ | |
let level = parseInt(obj.className.match(regex)[1]); | |
let chapter = obj.textContent; | |
md_str += `#${'#'.repeat(level)} ${chapter}\n`; | |
}); | |
GM_setClipboard(md_str); | |
}); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment