If you print the default page, you have too much irrelevant content, and the layout is not very good
Every time to manually adjust the style of the article, it seems very tedious, and then there is this small tool
The main use of the well-known web plugin TamperMonkey, commonly known as oil monkey
Plug-in installation
The Google Chrome plugin is available at www.extfans.com/
In Chrome, type chrome:// Extensions/into the browser address bar, open the development mode in the upper right corner, and drag the downloaded add-on in
Grease monkey plug-in
By grease monkey configuration, can let our script, in the pages of any load during operation, such as advertising on the page to intercept (use ready-made AdBlock much incense) directly, or do some customized with the specified page (e.g., here to share with everyone’s script), or to the current site HTTP requests to perform some don’t have to cross domain?
Developing a plug-in directly requires a specific directory structure and configuration requirements, which can be tedious. The Oil Monkey plug-in allows us to focus on writing JS scripts
Add a script
Enter the plugin icon in the toolbar to add a new script
Paste in all the code below, and then enable the script
This string of code mainly works on the gold-mining article page (which is matched by the regular URL in @match), listens for CTRL + P, blocks the default events, calls window.print() directly after the page has been adjusted, and finally restores the page
// ==UserScript==
// @name prints the nuggets article
// @namespace http://tampermonkey.net/
/ / @ version 0.1
// @description try to take over the world!
// @author
// @match https://juejin.cn/post/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
window.onload = function() {
document.onkeydown = function(e) {
if (e.ctrlKey && e.keyCode == 80) {
let old = document.body;
let html = document.getElementsByTagName('article');
document.body.outerHTML = html[0].outerHTML.replace(/ Copy code /g.' ');
document.body.style.padding = '30px';
html[0].getElementsByClassName('author-info-block') [0].outerHTML = ' ';
window.print();
document.body = old;
return false; }}}}) ();Copy the code
disadvantages
In the new article page directly printed words, there will be no picture, through F12 found that the http1.1 protocol, roughly in the form of the mouse scroll to a certain extent, automatically load the content of the next page, now just have an idea is in the call to print operation, let the page of pictures are triggered loading complete
The last
If you are using a different browser, go to the plugin center of your browser and if you can find an oil Monkey or similar plugin there, just click on it. If not, try dragging the Google plugin package into the extension to see if it works.