About a month ago, the external link of Weibo pictures failed, and the Nuggets also lost their links due to hotlink issues.2019/06/06Decided to open anti-leech, The impact is:The personal blog website quoted these pictures outside the chain can not be displayed。
Currently, the blocking of Weibo and Nuggets can be displayed normally in CSDN and segmentfault, which only affects personal blogs。
For example, my blog some time ago:http://obkoro1.comNone of the Weibo pictures quoted above can be displayed.
Because I write blogs frequently, there are not a few blocked pictures, so I definitely can’t replace them manually. I checked and didn’t find a ready-made solution. I made a script tool and wrote a document to open it up.
Search the markdown file in the target folder, find the target picture, provide the function of downloading the picture, and replacing the picture link-usually used for markdown picture failure.
This is an extremely lightweight script, reference the package, set the parameters, and easily get started through the API.
// 1. Download these two pictures
// 
// 
// 2. Replace with: github link


npm i markdown-img-down-site-change -S
You may not understand the function of the script when you are just getting started, and you need to debug it.markdownThe file is broken, don't you want to cry to death?
There are two forms of scripts to prevent this from happening:
There is a use in the projectchestnut, There are a lot of comments and blank lines, the actual code is less than 20 lines, it can be said that it is very simple, as follows:
// npm i markdown-img-down-site-change -S
const markdownImageDown = require('markdown-img-down-site-change'); // file module
// Passing parameters: This is also the default parameter of the script, you can modify it according to the situation
let option = {
replace_image_url: 'https://user-gold-cdn.xitu.io/',
read_markdown_src: './source', // To find the folder address of the markdown file
down_img_src: './juejin', // Download pictures to this folder
var_number: 3 // The number of variables in the first half of the url, such as the date above: /2019/5/20/, /2018/6/16/
}
// Initialize
const markdownImage = new markdownImageDown(option)
// Download external link
markdownImage.checkDownImg();
// Upload the downloaded image folder to the cloud, user operation
// After uploading the picture
// The script will replace the previous external link with a cloud address + splicing a picture name
markdownImage.updateOption({
new_image_url: 'https://xxx.com/directory address/', // The address of the picture upload
add_end: '?raw=true' // The github picture address has a suffix and goes directly to the warehouse
})
// Replace external link
// Replace the string of replace_image_url with a string of new_image_url
markdownImage.replaceMarkdown();
Read the text carefully and configure the parameters
Create a new one at the project root nodehandleImg.jsFile, install the script, and then usenodeRun the file:
npm i markdown-img-down-site-change -S
node handleImg.js
checkDownImg(): Download the found picturesreplaceMarkdown(): Replace the picture link with a new picture linkreplace_image_url: The address of the picture to be replacednew_image_url: The new address of the picturetest: Test mode.var_number: Match the url before the image name of the image link, the value is the variable quantityis_link: Match link.write_file_time: How often to modify the markdown image linkread_markdown_src: To find the folder address of the markdown filedown_img_src:Download pictures to this addresscopy_item_data: Backup projectfilter_item: Filter some folders without searching markdown.add_end: Add a suffix after the image linkFriends in need, come and try! The document is well written and easy to get started. The project will continue to be maintained. If you have any questions, please contact meissue~
If you think this script is not bad, giveprojectOrder a Star!
Blog、Front end accumulation document、No public, Wx:OBkoro1, email: [email protected]
Above 2019.06.04
IDEA solves assertion failure First of all, you have to go to IDEA to see if the assertion function is turned on? The assertion function needs to be turned on, it is turned off by default, and the met...
Qt is famous for his help documentation is very good, but in the natural state, after the qt4.8.1 is safe to use, even the input Widget can not find. Previously qt4.8.0, it is ok. No configuration is ...
One: Under the built web project, create a new lib folder, copy the external jar package used, and then correctly build-path, the unit test is completely fine, but after the project is released, an er...
Reprinted in the whole article, the original link:Gitee bed bed is blocked because of too many external links, what should we do Articles directory 1. Event cause Second, plan selection 3. Resource re...
Recently, I started learning Python and encountered the failure to install the python third-party library. Finally, I finally solved it with the help of Baidu. Here is how to successfully install pyth...
With the rapid development of informatization of the Internet of Things in recent years, the amount of data has also shown an exponential growth trend. Data visualization has gradually become the goal...
problem:The red box at the location below does not have an input box for adding JDK and SDK paths. We know that to package the android version of the application in Unity, you need to install the Java...
When we use WeChat marketing, it is easy to encounter the situation where the promotion link cannot be opened or the app cannot be downloaded in WeChat. First of all, let me talk about the problem tha...
1. Connect the computer's network cable port directly to the router's internal network interface (to ensure that the router can directly access the Internet normally, remember not to use broadband con...
A friend in my group asked this question: Everyone, please ask a question. The external breakpoint cannot be entered, and you need to set that place. Some enthusiastic friends in the group gave sugges...