Created
January 27, 2021 15:40
-
-
Save Matsuyanagi/1a091e543cae2f1c2353f6ba50d5fd53 to your computer and use it in GitHub Desktop.
Create Link markdown
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
name: | |
markdown | |
Format: | |
%title%\n%url% | |
filter: | |
const matches = s.match( /^(.+)\n([^\n]+)$/ );let title = matches[ 1 ];let url = matches[ 2 ];if ( url.match(/^https:\/\/www\.amazon\.co\.jp.*\/(dp|gp|ASIN|product)/) ){const dp_matches = url.match( /\/(dp|gp|ASIN|product)\/([0-9A-Z]{10})([^0-9A-Z])/ );const dp = "dp/" + dp_matches[ 2 ] + "/";url = "https://www.amazon.co.jp/" + dp;title = title.replace( / \| .*$/, "");title = title.replace( /[A-Za-z0-9]/g, c => String.fromCharCode(c.charCodeAt(0) - 0xFEE0) );title = title.replace( / /g, " ");}return "[" + title + "](" + url + ")"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment