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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"updatedAt": "2026-01-16T15:37:24.207Z",
|
| 3 |
+
"createdAt": "2026-01-11T16:13:38.061Z",
|
| 4 |
+
"id": "Ul4qc6sH2eCaTapb",
|
| 5 |
+
"name": "sino-trade-weekly-article-boost",
|
| 6 |
+
"active": true,
|
| 7 |
+
"isArchived": false,
|
| 8 |
+
"nodes": [
|
| 9 |
+
{
|
| 10 |
+
"parameters": {
|
| 11 |
+
"rule": {
|
| 12 |
+
"interval": [
|
| 13 |
+
{
|
| 14 |
+
"field": "weeks",
|
| 15 |
+
"triggerAtDay": [
|
| 16 |
+
2
|
| 17 |
+
],
|
| 18 |
+
"triggerAtHour": 21
|
| 19 |
+
}
|
| 20 |
+
]
|
| 21 |
+
}
|
| 22 |
+
},
|
| 23 |
+
"id": "ca2d85df-f90d-4cec-a4bb-a112407f6d8c",
|
| 24 |
+
"name": "Weekly Schedule",
|
| 25 |
+
"type": "n8n-nodes-base.scheduleTrigger",
|
| 26 |
+
"typeVersion": 1.2,
|
| 27 |
+
"position": [
|
| 28 |
+
-224,
|
| 29 |
+
144
|
| 30 |
+
]
|
| 31 |
+
},
|
| 32 |
+
{
|
| 33 |
+
"parameters": {
|
| 34 |
+
"method": "POST",
|
| 35 |
+
"url": "https://www.sinotrade.com.tw/richclub/api/graphql",
|
| 36 |
+
"sendHeaders": true,
|
| 37 |
+
"headerParameters": {
|
| 38 |
+
"parameters": [
|
| 39 |
+
{
|
| 40 |
+
"name": "Content-Type",
|
| 41 |
+
"value": "application/json"
|
| 42 |
+
}
|
| 43 |
+
]
|
| 44 |
+
},
|
| 45 |
+
"sendBody": true,
|
| 46 |
+
"specifyBody": "json",
|
| 47 |
+
"jsonBody": "{\n \"query\": \"query ($input: clientGetContentListInput) { clientGetArticleList(input: $input) { filtered { _id title media { totalView } } } }\",\n \"variables\": {\n \"input\": {\n \"sort\": {\n \"order\": \"desc\",\n \"column\": \"updatedAt\"\n },\n \"channel\": \"6514f8b3b13f2760605fcef1\",\n \"limit\": 1,\n \"page\": 0,\n \"skip\": 0\n }\n }\n}",
|
| 48 |
+
"options": {}
|
| 49 |
+
},
|
| 50 |
+
"id": "ee7518f8-201d-4579-8009-27d4a9ff233b",
|
| 51 |
+
"name": "Fetch 深談總經",
|
| 52 |
+
"type": "n8n-nodes-base.httpRequest",
|
| 53 |
+
"typeVersion": 4.2,
|
| 54 |
+
"position": [
|
| 55 |
+
0,
|
| 56 |
+
0
|
| 57 |
+
]
|
| 58 |
+
},
|
| 59 |
+
{
|
| 60 |
+
"parameters": {
|
| 61 |
+
"method": "POST",
|
| 62 |
+
"url": "https://www.sinotrade.com.tw/richclub/api/graphql",
|
| 63 |
+
"sendHeaders": true,
|
| 64 |
+
"headerParameters": {
|
| 65 |
+
"parameters": [
|
| 66 |
+
{
|
| 67 |
+
"name": "Content-Type",
|
| 68 |
+
"value": "application/json"
|
| 69 |
+
}
|
| 70 |
+
]
|
| 71 |
+
},
|
| 72 |
+
"sendBody": true,
|
| 73 |
+
"specifyBody": "json",
|
| 74 |
+
"jsonBody": "{\n \"query\": \"query ($input: clientGetContentListInput) { clientGetArticleList(input: $input) { filtered { _id title media { totalView } } } }\",\n \"variables\": {\n \"input\": {\n \"sort\": {\n \"order\": \"desc\",\n \"column\": \"updatedAt\"\n },\n \"channel\": \"630c2850c6435a2ff402ccfb\",\n \"limit\": 50,\n \"page\": 0,\n \"skip\": 0\n }\n }\n}",
|
| 75 |
+
"options": {}
|
| 76 |
+
},
|
| 77 |
+
"id": "ffd566c6-0b99-490f-a952-65e64fde8d15",
|
| 78 |
+
"name": "Fetch 川普專題",
|
| 79 |
+
"type": "n8n-nodes-base.httpRequest",
|
| 80 |
+
"typeVersion": 4.2,
|
| 81 |
+
"position": [
|
| 82 |
+
0,
|
| 83 |
+
304
|
| 84 |
+
]
|
| 85 |
+
},
|
| 86 |
+
{
|
| 87 |
+
"parameters": {
|
| 88 |
+
"jsCode": "// Extract the first article and build URL for 深談總經\nconst articles = $input.first().json.data.clientGetArticleList.filtered;\n\nif (!articles || articles.length === 0) {\n throw new Error('No articles found for 深談總經');\n}\n\nconst article = articles[0];\n\nfunction sanitizeTitle(title) {\n return title\n .replace(/[^\\u4e00-\\u9fff\\u3400-\\u4dbfa-zA-Z0-9]+/g, '-')\n .replace(/-+/g, '-')\n .replace(/^-|-$/g, '');\n}\n\nconst sanitizedTitle = sanitizeTitle(article.title);\nconst url = `https://www.sinotrade.com.tw/richclub/MacroExpert/${sanitizedTitle}--${article._id}`;\n\nreturn {\n json: {\n articleId: article._id,\n title: article.title,\n viewCount: article.media.totalView,\n url: url,\n channel: '深談總經',\n targetCount: 200\n }\n};"
|
| 89 |
+
},
|
| 90 |
+
"id": "dde6f938-982e-42b6-ad96-b6786f7fd311",
|
| 91 |
+
"name": "Build URL 深談總經",
|
| 92 |
+
"type": "n8n-nodes-base.code",
|
| 93 |
+
"typeVersion": 2,
|
| 94 |
+
"position": [
|
| 95 |
+
224,
|
| 96 |
+
0
|
| 97 |
+
]
|
| 98 |
+
},
|
| 99 |
+
{
|
| 100 |
+
"parameters": {
|
| 101 |
+
"jsCode": "// Extract articles and filter for 川普專題\nconst articles = $input.first().json.data.clientGetArticleList.filtered;\n\nif (!articles || articles.length === 0) {\n throw new Error('No articles found for 川普專題');\n}\n\n// Filter for articles with 【川普政策整理】 in title\nconst trumpArticles = articles.filter(a => a.title.includes('【川普政策整理】'));\n\nif (trumpArticles.length === 0) {\n throw new Error('No 川普專題 articles found with title filter');\n}\n\nconst article = trumpArticles[0];\n\nfunction sanitizeTitle(title) {\n return title\n .replace(/[^\\u4e00-\\u9fff\\u3400-\\u4dbfa-zA-Z0-9]+/g, '-')\n .replace(/-+/g, '-')\n .replace(/^-|-$/g, '');\n}\n\nconst sanitizedTitle = sanitizeTitle(article.title);\nconst url = `https://www.sinotrade.com.tw/richclub/hotstock/${sanitizedTitle}--${article._id}`;\n\nreturn {\n json: {\n articleId: article._id,\n title: article.title,\n viewCount: article.media.totalView,\n url: url,\n channel: '川普專題',\n targetCount: 2000\n }\n};"
|
| 102 |
+
},
|
| 103 |
+
"id": "6003619e-a147-4bdd-84fc-0a1e4eccefb2",
|
| 104 |
+
"name": "Build URL 川普專題",
|
| 105 |
+
"type": "n8n-nodes-base.code",
|
| 106 |
+
"typeVersion": 2,
|
| 107 |
+
"position": [
|
| 108 |
+
224,
|
| 109 |
+
304
|
| 110 |
+
]
|
| 111 |
+
},
|
| 112 |
+
{
|
| 113 |
+
"parameters": {
|
| 114 |
+
"jsCode": "// Build notification message\nlet macroResult = $('Boost View 深談總經').first().json\nlet trumpResult = $('Boost View 川普專題').first().json\n\nconst now = new Date().toLocaleString('zh-TW', { timeZone: 'Asia/Taipei' });\n\nreturn {\n json: {\n macroResult: {\n totalToRun: macroResult.totalToRun.toLocaleString(),\n successCount: macroResult.successCount.toLocaleString(),\n failCount: macroResult.failCount.toLocaleString(),\n oldViewCount: macroResult.oldViewCount.toLocaleString(),\n newViewCount: macroResult.newViewCount.toLocaleString(),\n successRate: macroResult.successRate,\n },\n trumpResult: {\n totalToRun: trumpResult.totalToRun.toLocaleString(),\n successCount: trumpResult.successCount.toLocaleString(),\n failCount: trumpResult.failCount.toLocaleString(),\n oldViewCount: trumpResult.oldViewCount.toLocaleString(),\n newViewCount: trumpResult.newViewCount.toLocaleString(),\n successRate: trumpResult.successRate,\n },,\n completedAt: now\n }\n};"
|
| 115 |
+
},
|
| 116 |
+
"id": "6a283323-578c-4d45-ba50-db97c0df9d29",
|
| 117 |
+
"name": "Build Notification",
|
| 118 |
+
"type": "n8n-nodes-base.code",
|
| 119 |
+
"typeVersion": 2,
|
| 120 |
+
"position": [
|
| 121 |
+
960,
|
| 122 |
+
144
|
| 123 |
+
]
|
| 124 |
+
},
|
| 125 |
+
{
|
| 126 |
+
"parameters": {
|
| 127 |
+
"jsCode": "/**\n * Optimized for '深談總經' (200 Requests)\n * Pattern: Chunked Batching (Size 5)\n */\n\nconst fetch = require('node-fetch');\n\n// --- Helper: Get a Random UA ---\nfunction getRandomUA() {\n const uas = [\n 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) Chrome/131.0.0.0 Safari/537.36',\n 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) Safari/605.1.15',\n 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_6 like Mac OS X) Safari/604.1'\n ];\n return uas[Math.floor(Math.random() * uas.length)];\n}\n\n// --- Helper: Process Batch ---\nasync function processBatch(url, size) {\n const tasks = [];\n for (let i = 0; i < size; i++) {\n const ua = getRandomUA(); // Generated exactly when needed\n tasks.push(\n fetch(url, {\n method: 'GET',\n headers: { 'User-Agent': ua },\n })\n .then(res => res.ok)\n .catch(() => false)\n );\n }\n return await Promise.all(tasks);\n}\n\n// --- Main Logic ---\nasync function main() {\n const sourceNode = $('Build URL 深談總經').first().json;\n const targetUrl = sourceNode.url;\n const totalToRun = 200; // Smaller count for this channel\n const chunkSize = 5; \n \n let successCount = 0;\n let failCount = 0;\n\n for (let i = 0; i < totalToRun; i += chunkSize) {\n // Determine the size of the current batch (handles the remainder)\n const currentBatchSize = Math.min(chunkSize, totalToRun - i);\n \n const results = await processBatch(targetUrl, currentBatchSize);\n results.forEach(res => res ? successCount++ : failCount++);\n\n if (i + chunkSize < totalToRun) {\n await new Promise(res => setTimeout(res, 300));\n }\n }\n\n return {\n json: {\n channel: '深談總經',\n title: sourceNode.title,\n totalToRun,\n successCount,\n failCount,\n oldViewCount: sourceNode.viewCount,\n newViewCount: sourceNode.viewCount + successCount,\n successRate: ((successCount / totalToRun) * 100).toFixed(0) + '%'\n }\n };\n}\n\nreturn main();"
|
| 128 |
+
},
|
| 129 |
+
"type": "n8n-nodes-base.code",
|
| 130 |
+
"typeVersion": 2,
|
| 131 |
+
"position": [
|
| 132 |
+
464,
|
| 133 |
+
0
|
| 134 |
+
],
|
| 135 |
+
"id": "c5f82a7a-98f8-4a51-aff7-8d3c9cb6b3a6",
|
| 136 |
+
"name": "Boost View 深談總經"
|
| 137 |
+
},
|
| 138 |
+
{
|
| 139 |
+
"parameters": {
|
| 140 |
+
"jsCode": "/**\n * Optimized for '川普專題' (2000 Requests)\n * Pattern: Chunked Batching (Size 5)\n */\n\nconst fetch = require('node-fetch');\n\n// --- Helper: Get a Random UA ---\nfunction getRandomUA() {\n const uas = [\n 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) Chrome/131.0.0.0 Safari/537.36',\n 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) Safari/605.1.15',\n 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_6 like Mac OS X) Safari/604.1'\n ];\n return uas[Math.floor(Math.random() * uas.length)];\n}\n\n// --- Helper: Process Batch ---\nasync function processBatch(url, size) {\n const tasks = [];\n for (let i = 0; i < size; i++) {\n const ua = getRandomUA(); // Generated exactly when needed\n tasks.push(\n fetch(url, {\n method: 'GET',\n headers: { 'User-Agent': ua },\n })\n .then(res => res.ok)\n .catch(() => false)\n );\n }\n return await Promise.all(tasks);\n}\n\n// --- Main Execution Logic ---\nasync function main() {\n const sourceNode = $('Build URL 川普專題').first().json;\n const targetUrl = sourceNode.url;\n const totalToRun = 2000;\n const chunkSize = 5;\n \n let successCount = 0;\n let failCount = 0;\n\n for (let i = 0; i < totalToRun; i += chunkSize) {\n // Determine the size of the current batch (handles the remainder)\n const currentBatchSize = Math.min(chunkSize, totalToRun - i);\n \n const results = await processBatch(targetUrl, currentBatchSize);\n results.forEach(res => res ? successCount++ : failCount++);\n\n if (i + chunkSize < totalToRun) {\n await new Promise(res => setTimeout(res, 300));\n }\n }\n\n return {\n json: {\n channel: '川普專題',\n title: sourceNode.title,\n totalToRun,\n successCount,\n failCount,\n newViewCount: sourceNode.viewCount + successCount,\n successRate: ((successCount / totalToRun) * 100).toFixed(0) + '%'\n }\n };\n}\n\n// n8n expects the final return to be the result of the function call\nreturn main();"
|
| 141 |
+
},
|
| 142 |
+
"type": "n8n-nodes-base.code",
|
| 143 |
+
"typeVersion": 2,
|
| 144 |
+
"position": [
|
| 145 |
+
464,
|
| 146 |
+
304
|
| 147 |
+
],
|
| 148 |
+
"id": "5d7dc4bc-9f60-4e83-878f-bf47a16b0209",
|
| 149 |
+
"name": "Boost View 川普專題"
|
| 150 |
+
},
|
| 151 |
+
{
|
| 152 |
+
"parameters": {
|
| 153 |
+
"authentication": "webhook",
|
| 154 |
+
"content": "={{ $json.message }}",
|
| 155 |
+
"options": {}
|
| 156 |
+
},
|
| 157 |
+
"type": "n8n-nodes-base.discord",
|
| 158 |
+
"typeVersion": 2,
|
| 159 |
+
"position": [
|
| 160 |
+
1184,
|
| 161 |
+
-16
|
| 162 |
+
],
|
| 163 |
+
"id": "1ef12db6-b1ed-4689-a0a3-da6c067f254b",
|
| 164 |
+
"name": "Notify Discord",
|
| 165 |
+
"webhookId": "a2cf639d-4a4a-4391-b665-269703327916",
|
| 166 |
+
"credentials": {
|
| 167 |
+
"discordWebhookApi": {
|
| 168 |
+
"id": "PgAS3Za8Re1XFY1H",
|
| 169 |
+
"name": "Discord Webhook account"
|
| 170 |
+
}
|
| 171 |
+
}
|
| 172 |
+
},
|
| 173 |
+
{
|
| 174 |
+
"parameters": {
|
| 175 |
+
"mode": "combine",
|
| 176 |
+
"combineBy": "combineByPosition",
|
| 177 |
+
"options": {}
|
| 178 |
+
},
|
| 179 |
+
"type": "n8n-nodes-base.merge",
|
| 180 |
+
"typeVersion": 3.2,
|
| 181 |
+
"position": [
|
| 182 |
+
752,
|
| 183 |
+
144
|
| 184 |
+
],
|
| 185 |
+
"id": "78253ec2-aa76-406d-93b0-bc34e3727c22",
|
| 186 |
+
"name": "Merge"
|
| 187 |
+
},
|
| 188 |
+
{
|
| 189 |
+
"parameters": {
|
| 190 |
+
"method": "POST",
|
| 191 |
+
"url": "https://api.line.me/v2/bot/message/push",
|
| 192 |
+
"authentication": "genericCredentialType",
|
| 193 |
+
"genericAuthType": "httpBearerAuth",
|
| 194 |
+
"sendBody": true,
|
| 195 |
+
"specifyBody": "json",
|
| 196 |
+
"jsonBody": "={{\n JSON.stringify({\n \"to\": \"C07043bf7944b51ee170ec5f4092e9b54\",\n \"messages\": [\n {\n \"sender\": {\n \"name\": \"豐雲學堂\",\n \"iconUrl\": \"https://richclub.azureedge.net/public/android-icon-144x144.png\"\n },\n \"type\": \"flex\",\n \"altText\": \"本周深談總經及川普專題的執行已結束,請察看結果。\",\n \"contents\": {\n \"type\": \"carousel\",\n \"contents\": [\n {\n \"type\": \"bubble\",\n \"hero\": {\n \"type\": \"image\",\n \"url\": `https://richclub.azureedge.net/article/${$('Build URL 深談總經').first().json.articleId}/poster.jpg`,\n \"size\": \"full\",\n \"aspectRatio\": \"20:13\",\n \"aspectMode\": \"cover\"\n },\n \"body\": {\n \"type\": \"box\",\n \"layout\": \"vertical\",\n \"contents\": [\n { \"type\": \"text\", \"text\": \"深談總經\", \"weight\": \"bold\", \"size\": \"xl\", \"color\": \"#1DB446\" },\n { \"type\": \"text\", \"text\": $('Build URL 深談總經').first().json.title, \"size\": \"xs\", \"color\": \"#8c8c8c\", \"wrap\": true, \"margin\": \"md\" },\n { \"type\": \"separator\", \"margin\": \"lg\" },\n {\n \"type\": \"box\",\n \"layout\": \"vertical\",\n \"margin\": \"lg\",\n \"spacing\": \"sm\",\n \"contents\": [\n { \"type\": \"box\", \"layout\": \"baseline\", \"spacing\": \"sm\", \"contents\": [\n { \"type\": \"text\", \"text\": \"執行/成功\", \"color\": \"#aaaaaa\", \"size\": \"sm\", \"flex\": 2 },\n { \"type\": \"text\", \"text\": `${$node[\"Build Notification\"].json.macroResult.totalToRun} / ${$node[\"Build Notification\"].json.macroResult.successCount}`, \"wrap\": true, \"color\": \"#666666\", \"size\": \"sm\", \"flex\": 4 }\n ]},\n { \"type\": \"box\", \"layout\": \"baseline\", \"spacing\": \"sm\", \"contents\": [\n { \"type\": \"text\", \"text\": \"成功率\", \"color\": \"#aaaaaa\", \"size\": \"sm\", \"flex\": 2 },\n { \"type\": \"text\", \"text\": $node[\"Build Notification\"].json.macroResult.successRate, \"wrap\": true, \"color\": \"#1DB446\", \"size\": \"sm\", \"weight\": \"bold\", \"flex\": 4 }\n ]},\n { \"type\": \"box\", \"layout\": \"baseline\", \"spacing\": \"sm\", \"contents\": [\n { \"type\": \"text\", \"text\": \"最終觀看\", \"color\": \"#aaaaaa\", \"size\": \"sm\", \"flex\": 2 },\n { \"type\": \"text\", \"text\": String($node[\"Build Notification\"].json.macroResult.newViewCount), \"wrap\": true, \"color\": \"#666666\", \"size\": \"sm\", \"flex\": 4 }\n ]}\n ]\n }\n ]\n },\n \"footer\": {\n \"type\": \"box\",\n \"layout\": \"vertical\",\n \"spacing\": \"sm\",\n \"contents\": [\n { \"type\": \"button\", \"style\": \"link\", \"height\": \"sm\", \"action\": { \"type\": \"uri\", \"label\": \"查看文章\", \"uri\": $('Build URL 深談總經').first().json.url } },\n { \"type\": \"text\", \"text\": `完成於: ${new Date().toLocaleString('zh-TW', { timeZone: 'Asia/Taipei' })}`, \"size\": \"xxs\", \"color\": \"#cccccc\", \"align\": \"center\" }\n ]\n }\n },\n {\n \"type\": \"bubble\",\n \"hero\": {\n \"type\": \"image\",\n \"url\": `https://richclub.azureedge.net/article/${$('Build URL 川普專題').first().json.articleId}/poster.jpg`,\n \"size\": \"full\",\n \"aspectRatio\": \"20:13\",\n \"aspectMode\": \"cover\"\n },\n \"body\": {\n \"type\": \"box\",\n \"layout\": \"vertical\",\n \"contents\": [\n { \"type\": \"text\", \"text\": \"川普專題\", \"weight\": \"bold\", \"size\": \"xl\", \"color\": \"#0055ff\" },\n { \"type\": \"text\", \"text\": $('Build URL 川普專題').first().json.title, \"size\": \"xs\", \"color\": \"#8c8c8c\", \"wrap\": true, \"margin\": \"md\" },\n { \"type\": \"separator\", \"margin\": \"lg\" },\n {\n \"type\": \"box\",\n \"layout\": \"vertical\",\n \"margin\": \"lg\",\n \"spacing\": \"sm\",\n \"contents\": [\n { \"type\": \"box\", \"layout\": \"baseline\", \"spacing\": \"sm\", \"contents\": [\n { \"type\": \"text\", \"text\": \"執行/成功\", \"color\": \"#aaaaaa\", \"size\": \"sm\", \"flex\": 2 },\n { \"type\": \"text\", \"text\": `${$node[\"Build Notification\"].json.trumpResult.totalRequests} / ${$node[\"Build Notification\"].json.successCount}`, \"wrap\": true, \"color\": \"#666666\", \"size\": \"sm\", \"flex\": 4 }\n ]},\n { \"type\": \"box\", \"layout\": \"baseline\", \"spacing\": \"sm\", \"contents\": [\n { \"type\": \"text\", \"text\": \"成功率\", \"color\": \"#aaaaaa\", \"size\": \"sm\", \"flex\": 2 },\n { \"type\": \"text\", \"text\": $node[\"Build Notification\"].json.trumpResult.successRate, \"wrap\": true, \"color\": \"#1DB446\", \"size\": \"sm\", \"weight\": \"bold\", \"flex\": 4 }\n ]},\n { \"type\": \"box\", \"layout\": \"baseline\", \"spacing\": \"sm\", \"contents\": [\n { \"type\": \"text\", \"text\": \"最終觀看\", \"color\": \"#aaaaaa\", \"size\": \"sm\", \"flex\": 2 },\n { \"type\": \"text\", \"text\": String($node[\"Build Notification\"].json.trumpResult.newViewCount), \"wrap\": true, \"color\": \"#666666\", \"size\": \"sm\", \"flex\": 4 }\n ]}\n ]\n }\n ]\n },\n \"footer\": {\n \"type\": \"box\",\n \"layout\": \"vertical\",\n \"spacing\": \"sm\",\n \"contents\": [\n { \"type\": \"button\", \"style\": \"link\", \"height\": \"sm\", \"action\": { \"type\": \"uri\", \"label\": \"查看文章\", \"uri\": $('Build URL 川普專題').first().json.url } },\n { \"type\": \"text\", \"text\": `完成於: ${new Date().toLocaleString('zh-TW', { timeZone: 'Asia/Taipei' })}`, \"size\": \"xxs\", \"color\": \"#cccccc\", \"align\": \"center\" }\n ]\n }\n }\n ]\n }\n }\n ]\n })\n}}",
|
| 197 |
+
"options": {}
|
| 198 |
+
},
|
| 199 |
+
"type": "n8n-nodes-base.httpRequest",
|
| 200 |
+
"typeVersion": 4.3,
|
| 201 |
+
"position": [
|
| 202 |
+
1184,
|
| 203 |
+
304
|
| 204 |
+
],
|
| 205 |
+
"id": "8efd2189-96f6-49b4-94f3-89a90ca64ef2",
|
| 206 |
+
"name": "Notify Line",
|
| 207 |
+
"credentials": {
|
| 208 |
+
"httpBearerAuth": {
|
| 209 |
+
"id": "iJvKQKPJqm4Bdr83",
|
| 210 |
+
"name": "Bearer Auth account"
|
| 211 |
+
}
|
| 212 |
+
}
|
| 213 |
+
}
|
| 214 |
+
],
|
| 215 |
+
"connections": {
|
| 216 |
+
"Weekly Schedule": {
|
| 217 |
+
"main": [
|
| 218 |
+
[
|
| 219 |
+
{
|
| 220 |
+
"node": "Fetch 深談總經",
|
| 221 |
+
"type": "main",
|
| 222 |
+
"index": 0
|
| 223 |
+
},
|
| 224 |
+
{
|
| 225 |
+
"node": "Fetch 川普專題",
|
| 226 |
+
"type": "main",
|
| 227 |
+
"index": 0
|
| 228 |
+
}
|
| 229 |
+
]
|
| 230 |
+
]
|
| 231 |
+
},
|
| 232 |
+
"Fetch 深談總經": {
|
| 233 |
+
"main": [
|
| 234 |
+
[
|
| 235 |
+
{
|
| 236 |
+
"node": "Build URL 深談總經",
|
| 237 |
+
"type": "main",
|
| 238 |
+
"index": 0
|
| 239 |
+
}
|
| 240 |
+
]
|
| 241 |
+
]
|
| 242 |
+
},
|
| 243 |
+
"Fetch 川普專題": {
|
| 244 |
+
"main": [
|
| 245 |
+
[
|
| 246 |
+
{
|
| 247 |
+
"node": "Build URL 川普專題",
|
| 248 |
+
"type": "main",
|
| 249 |
+
"index": 0
|
| 250 |
+
}
|
| 251 |
+
]
|
| 252 |
+
]
|
| 253 |
+
},
|
| 254 |
+
"Build URL 深談總經": {
|
| 255 |
+
"main": [
|
| 256 |
+
[
|
| 257 |
+
{
|
| 258 |
+
"node": "Boost View 深談總經",
|
| 259 |
+
"type": "main",
|
| 260 |
+
"index": 0
|
| 261 |
+
}
|
| 262 |
+
]
|
| 263 |
+
]
|
| 264 |
+
},
|
| 265 |
+
"Build URL 川普專題": {
|
| 266 |
+
"main": [
|
| 267 |
+
[
|
| 268 |
+
{
|
| 269 |
+
"node": "Boost View 川普專題",
|
| 270 |
+
"type": "main",
|
| 271 |
+
"index": 0
|
| 272 |
+
}
|
| 273 |
+
]
|
| 274 |
+
]
|
| 275 |
+
},
|
| 276 |
+
"Build Notification": {
|
| 277 |
+
"main": [
|
| 278 |
+
[
|
| 279 |
+
{
|
| 280 |
+
"node": "Notify Discord",
|
| 281 |
+
"type": "main",
|
| 282 |
+
"index": 0
|
| 283 |
+
},
|
| 284 |
+
{
|
| 285 |
+
"node": "Notify Line",
|
| 286 |
+
"type": "main",
|
| 287 |
+
"index": 0
|
| 288 |
+
}
|
| 289 |
+
]
|
| 290 |
+
]
|
| 291 |
+
},
|
| 292 |
+
"Boost View 深談總經": {
|
| 293 |
+
"main": [
|
| 294 |
+
[
|
| 295 |
+
{
|
| 296 |
+
"node": "Merge",
|
| 297 |
+
"type": "main",
|
| 298 |
+
"index": 0
|
| 299 |
+
}
|
| 300 |
+
]
|
| 301 |
+
]
|
| 302 |
+
},
|
| 303 |
+
"Boost View 川普專題": {
|
| 304 |
+
"main": [
|
| 305 |
+
[
|
| 306 |
+
{
|
| 307 |
+
"node": "Merge",
|
| 308 |
+
"type": "main",
|
| 309 |
+
"index": 1
|
| 310 |
+
}
|
| 311 |
+
]
|
| 312 |
+
]
|
| 313 |
+
},
|
| 314 |
+
"Notify Discord": {
|
| 315 |
+
"main": [
|
| 316 |
+
[]
|
| 317 |
+
]
|
| 318 |
+
},
|
| 319 |
+
"Merge": {
|
| 320 |
+
"main": [
|
| 321 |
+
[
|
| 322 |
+
{
|
| 323 |
+
"node": "Build Notification",
|
| 324 |
+
"type": "main",
|
| 325 |
+
"index": 0
|
| 326 |
+
}
|
| 327 |
+
]
|
| 328 |
+
]
|
| 329 |
+
}
|
| 330 |
+
},
|
| 331 |
+
"settings": {
|
| 332 |
+
"executionOrder": "v1",
|
| 333 |
+
"availableInMCP": false
|
| 334 |
+
},
|
| 335 |
+
"staticData": {
|
| 336 |
+
"node:Weekly Schedule": {
|
| 337 |
+
"recurrenceRules": []
|
| 338 |
+
}
|
| 339 |
+
},
|
| 340 |
+
"meta": {
|
| 341 |
+
"templateCredsSetupCompleted": true
|
| 342 |
+
},
|
| 343 |
+
"pinData": {},
|
| 344 |
+
"versionId": "b6375c65-bd96-4e11-a138-aceb16e55f6b",
|
| 345 |
+
"activeVersionId": "b6375c65-bd96-4e11-a138-aceb16e55f6b",
|
| 346 |
+
"triggerCount": 1,
|
| 347 |
+
"shared": [
|
| 348 |
+
{
|
| 349 |
+
"updatedAt": "2026-01-11T16:13:38.061Z",
|
| 350 |
+
"createdAt": "2026-01-11T16:13:38.061Z",
|
| 351 |
+
"role": "workflow:owner",
|
| 352 |
+
"workflowId": "Ul4qc6sH2eCaTapb",
|
| 353 |
+
"projectId": "1yHpLTrY34GY4WHm"
|
| 354 |
+
}
|
| 355 |
+
],
|
| 356 |
+
"activeVersion": {
|
| 357 |
+
"updatedAt": "2026-01-14T06:56:15.066Z",
|
| 358 |
+
"createdAt": "2026-01-14T06:55:43.963Z",
|
| 359 |
+
"versionId": "b6375c65-bd96-4e11-a138-aceb16e55f6b",
|
| 360 |
+
"workflowId": "Ul4qc6sH2eCaTapb",
|
| 361 |
+
"nodes": [
|
| 362 |
+
{
|
| 363 |
+
"parameters": {
|
| 364 |
+
"rule": {
|
| 365 |
+
"interval": [
|
| 366 |
+
{
|
| 367 |
+
"field": "weeks",
|
| 368 |
+
"triggerAtDay": [
|
| 369 |
+
2
|
| 370 |
+
],
|
| 371 |
+
"triggerAtHour": 21
|
| 372 |
+
}
|
| 373 |
+
]
|
| 374 |
+
}
|
| 375 |
+
},
|
| 376 |
+
"id": "ca2d85df-f90d-4cec-a4bb-a112407f6d8c",
|
| 377 |
+
"name": "Weekly Schedule",
|
| 378 |
+
"type": "n8n-nodes-base.scheduleTrigger",
|
| 379 |
+
"typeVersion": 1.2,
|
| 380 |
+
"position": [
|
| 381 |
+
-224,
|
| 382 |
+
144
|
| 383 |
+
]
|
| 384 |
+
},
|
| 385 |
+
{
|
| 386 |
+
"parameters": {
|
| 387 |
+
"method": "POST",
|
| 388 |
+
"url": "https://www.sinotrade.com.tw/richclub/api/graphql",
|
| 389 |
+
"sendHeaders": true,
|
| 390 |
+
"headerParameters": {
|
| 391 |
+
"parameters": [
|
| 392 |
+
{
|
| 393 |
+
"name": "Content-Type",
|
| 394 |
+
"value": "application/json"
|
| 395 |
+
}
|
| 396 |
+
]
|
| 397 |
+
},
|
| 398 |
+
"sendBody": true,
|
| 399 |
+
"specifyBody": "json",
|
| 400 |
+
"jsonBody": "{\n \"query\": \"query ($input: clientGetContentListInput) { clientGetArticleList(input: $input) { filtered { _id title media { totalView } } } }\",\n \"variables\": {\n \"input\": {\n \"sort\": {\n \"order\": \"desc\",\n \"column\": \"updatedAt\"\n },\n \"channel\": \"6514f8b3b13f2760605fcef1\",\n \"limit\": 1,\n \"page\": 0,\n \"skip\": 0\n }\n }\n}",
|
| 401 |
+
"options": {}
|
| 402 |
+
},
|
| 403 |
+
"id": "ee7518f8-201d-4579-8009-27d4a9ff233b",
|
| 404 |
+
"name": "Fetch 深談總經",
|
| 405 |
+
"type": "n8n-nodes-base.httpRequest",
|
| 406 |
+
"typeVersion": 4.2,
|
| 407 |
+
"position": [
|
| 408 |
+
0,
|
| 409 |
+
0
|
| 410 |
+
]
|
| 411 |
+
},
|
| 412 |
+
{
|
| 413 |
+
"parameters": {
|
| 414 |
+
"method": "POST",
|
| 415 |
+
"url": "https://www.sinotrade.com.tw/richclub/api/graphql",
|
| 416 |
+
"sendHeaders": true,
|
| 417 |
+
"headerParameters": {
|
| 418 |
+
"parameters": [
|
| 419 |
+
{
|
| 420 |
+
"name": "Content-Type",
|
| 421 |
+
"value": "application/json"
|
| 422 |
+
}
|
| 423 |
+
]
|
| 424 |
+
},
|
| 425 |
+
"sendBody": true,
|
| 426 |
+
"specifyBody": "json",
|
| 427 |
+
"jsonBody": "{\n \"query\": \"query ($input: clientGetContentListInput) { clientGetArticleList(input: $input) { filtered { _id title media { totalView } } } }\",\n \"variables\": {\n \"input\": {\n \"sort\": {\n \"order\": \"desc\",\n \"column\": \"updatedAt\"\n },\n \"channel\": \"630c2850c6435a2ff402ccfb\",\n \"limit\": 50,\n \"page\": 0,\n \"skip\": 0\n }\n }\n}",
|
| 428 |
+
"options": {}
|
| 429 |
+
},
|
| 430 |
+
"id": "ffd566c6-0b99-490f-a952-65e64fde8d15",
|
| 431 |
+
"name": "Fetch 川普專題",
|
| 432 |
+
"type": "n8n-nodes-base.httpRequest",
|
| 433 |
+
"typeVersion": 4.2,
|
| 434 |
+
"position": [
|
| 435 |
+
0,
|
| 436 |
+
304
|
| 437 |
+
]
|
| 438 |
+
},
|
| 439 |
+
{
|
| 440 |
+
"parameters": {
|
| 441 |
+
"jsCode": "// Extract the first article and build URL for 深談總經\nconst articles = $input.first().json.data.clientGetArticleList.filtered;\n\nif (!articles || articles.length === 0) {\n throw new Error('No articles found for 深談總經');\n}\n\nconst article = articles[0];\n\nfunction sanitizeTitle(title) {\n return title\n .replace(/[^\\u4e00-\\u9fff\\u3400-\\u4dbfa-zA-Z0-9]+/g, '-')\n .replace(/-+/g, '-')\n .replace(/^-|-$/g, '');\n}\n\nconst sanitizedTitle = sanitizeTitle(article.title);\nconst url = `https://www.sinotrade.com.tw/richclub/MacroExpert/${sanitizedTitle}--${article._id}`;\n\nreturn {\n json: {\n articleId: article._id,\n title: article.title,\n viewCount: article.media.totalView,\n url: url,\n channel: '深談總經',\n targetCount: 200\n }\n};"
|
| 442 |
+
},
|
| 443 |
+
"id": "dde6f938-982e-42b6-ad96-b6786f7fd311",
|
| 444 |
+
"name": "Build URL 深談總經",
|
| 445 |
+
"type": "n8n-nodes-base.code",
|
| 446 |
+
"typeVersion": 2,
|
| 447 |
+
"position": [
|
| 448 |
+
224,
|
| 449 |
+
0
|
| 450 |
+
]
|
| 451 |
+
},
|
| 452 |
+
{
|
| 453 |
+
"parameters": {
|
| 454 |
+
"jsCode": "// Extract articles and filter for 川普專題\nconst articles = $input.first().json.data.clientGetArticleList.filtered;\n\nif (!articles || articles.length === 0) {\n throw new Error('No articles found for 川普專題');\n}\n\n// Filter for articles with 【川普政策整理】 in title\nconst trumpArticles = articles.filter(a => a.title.includes('【川普政策整理】'));\n\nif (trumpArticles.length === 0) {\n throw new Error('No 川普專題 articles found with title filter');\n}\n\nconst article = trumpArticles[0];\n\nfunction sanitizeTitle(title) {\n return title\n .replace(/[^\\u4e00-\\u9fff\\u3400-\\u4dbfa-zA-Z0-9]+/g, '-')\n .replace(/-+/g, '-')\n .replace(/^-|-$/g, '');\n}\n\nconst sanitizedTitle = sanitizeTitle(article.title);\nconst url = `https://www.sinotrade.com.tw/richclub/hotstock/${sanitizedTitle}--${article._id}`;\n\nreturn {\n json: {\n articleId: article._id,\n title: article.title,\n viewCount: article.media.totalView,\n url: url,\n channel: '川普專題',\n targetCount: 2000\n }\n};"
|
| 455 |
+
},
|
| 456 |
+
"id": "6003619e-a147-4bdd-84fc-0a1e4eccefb2",
|
| 457 |
+
"name": "Build URL 川普專題",
|
| 458 |
+
"type": "n8n-nodes-base.code",
|
| 459 |
+
"typeVersion": 2,
|
| 460 |
+
"position": [
|
| 461 |
+
224,
|
| 462 |
+
304
|
| 463 |
+
]
|
| 464 |
+
},
|
| 465 |
+
{
|
| 466 |
+
"parameters": {
|
| 467 |
+
"jsCode": "// Build notification message\nlet macroResult = $('Boost View 深談總經').first().json\nlet trumpResult = $('Boost View 川普專題').first().json\n\nconst now = new Date().toLocaleString('zh-TW', { timeZone: 'Asia/Taipei' });\n\nreturn {\n json: {\n macroResult: {\n totalToRun: macroResult.totalToRun.toLocaleString(),\n successCount: macroResult.successCount.toLocaleString(),\n failCount: macroResult.failCount.toLocaleString(),\n oldViewCount: macroResult.oldViewCount.toLocaleString(),\n newViewCount: macroResult.newViewCount.toLocaleString(),\n successRate: macroResult.successRate,\n },\n trumpResult: {\n totalToRun: trumpResult.totalToRun.toLocaleString(),\n successCount: trumpResult.successCount.toLocaleString(),\n failCount: trumpResult.failCount.toLocaleString(),\n oldViewCount: trumpResult.oldViewCount.toLocaleString(),\n newViewCount: trumpResult.newViewCount.toLocaleString(),\n successRate: trumpResult.successRate,\n },,\n completedAt: now\n }\n};"
|
| 468 |
+
},
|
| 469 |
+
"id": "6a283323-578c-4d45-ba50-db97c0df9d29",
|
| 470 |
+
"name": "Build Notification",
|
| 471 |
+
"type": "n8n-nodes-base.code",
|
| 472 |
+
"typeVersion": 2,
|
| 473 |
+
"position": [
|
| 474 |
+
960,
|
| 475 |
+
144
|
| 476 |
+
]
|
| 477 |
+
},
|
| 478 |
+
{
|
| 479 |
+
"parameters": {
|
| 480 |
+
"jsCode": "/**\n * Optimized for '深談總經' (200 Requests)\n * Pattern: Chunked Batching (Size 5)\n */\n\nconst fetch = require('node-fetch');\n\n// --- Helper: Get a Random UA ---\nfunction getRandomUA() {\n const uas = [\n 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) Chrome/131.0.0.0 Safari/537.36',\n 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) Safari/605.1.15',\n 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_6 like Mac OS X) Safari/604.1'\n ];\n return uas[Math.floor(Math.random() * uas.length)];\n}\n\n// --- Helper: Process Batch ---\nasync function processBatch(url, size) {\n const tasks = [];\n for (let i = 0; i < size; i++) {\n const ua = getRandomUA(); // Generated exactly when needed\n tasks.push(\n fetch(url, {\n method: 'GET',\n headers: { 'User-Agent': ua },\n })\n .then(res => res.ok)\n .catch(() => false)\n );\n }\n return await Promise.all(tasks);\n}\n\n// --- Main Logic ---\nasync function main() {\n const sourceNode = $('Build URL 深談總經').first().json;\n const targetUrl = sourceNode.url;\n const totalToRun = 200; // Smaller count for this channel\n const chunkSize = 5; \n \n let successCount = 0;\n let failCount = 0;\n\n for (let i = 0; i < totalToRun; i += chunkSize) {\n // Determine the size of the current batch (handles the remainder)\n const currentBatchSize = Math.min(chunkSize, totalToRun - i);\n \n const results = await processBatch(targetUrl, currentBatchSize);\n results.forEach(res => res ? successCount++ : failCount++);\n\n if (i + chunkSize < totalToRun) {\n await new Promise(res => setTimeout(res, 300));\n }\n }\n\n return {\n json: {\n channel: '深談總經',\n title: sourceNode.title,\n totalToRun,\n successCount,\n failCount,\n oldViewCount: sourceNode.viewCount,\n newViewCount: sourceNode.viewCount + successCount,\n successRate: ((successCount / totalToRun) * 100).toFixed(0) + '%'\n }\n };\n}\n\nreturn main();"
|
| 481 |
+
},
|
| 482 |
+
"type": "n8n-nodes-base.code",
|
| 483 |
+
"typeVersion": 2,
|
| 484 |
+
"position": [
|
| 485 |
+
464,
|
| 486 |
+
0
|
| 487 |
+
],
|
| 488 |
+
"id": "c5f82a7a-98f8-4a51-aff7-8d3c9cb6b3a6",
|
| 489 |
+
"name": "Boost View 深談總經"
|
| 490 |
+
},
|
| 491 |
+
{
|
| 492 |
+
"parameters": {
|
| 493 |
+
"jsCode": "/**\n * Optimized for '川普專題' (2000 Requests)\n * Pattern: Chunked Batching (Size 5)\n */\n\nconst fetch = require('node-fetch');\n\n// --- Helper: Get a Random UA ---\nfunction getRandomUA() {\n const uas = [\n 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) Chrome/131.0.0.0 Safari/537.36',\n 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) Safari/605.1.15',\n 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_6 like Mac OS X) Safari/604.1'\n ];\n return uas[Math.floor(Math.random() * uas.length)];\n}\n\n// --- Helper: Process Batch ---\nasync function processBatch(url, size) {\n const tasks = [];\n for (let i = 0; i < size; i++) {\n const ua = getRandomUA(); // Generated exactly when needed\n tasks.push(\n fetch(url, {\n method: 'GET',\n headers: { 'User-Agent': ua },\n })\n .then(res => res.ok)\n .catch(() => false)\n );\n }\n return await Promise.all(tasks);\n}\n\n// --- Main Execution Logic ---\nasync function main() {\n const sourceNode = $('Build URL 川普專題').first().json;\n const targetUrl = sourceNode.url;\n const totalToRun = 2000;\n const chunkSize = 5;\n \n let successCount = 0;\n let failCount = 0;\n\n for (let i = 0; i < totalToRun; i += chunkSize) {\n // Determine the size of the current batch (handles the remainder)\n const currentBatchSize = Math.min(chunkSize, totalToRun - i);\n \n const results = await processBatch(targetUrl, currentBatchSize);\n results.forEach(res => res ? successCount++ : failCount++);\n\n if (i + chunkSize < totalToRun) {\n await new Promise(res => setTimeout(res, 300));\n }\n }\n\n return {\n json: {\n channel: '川普專題',\n title: sourceNode.title,\n totalToRun,\n successCount,\n failCount,\n newViewCount: sourceNode.viewCount + successCount,\n successRate: ((successCount / totalToRun) * 100).toFixed(0) + '%'\n }\n };\n}\n\n// n8n expects the final return to be the result of the function call\nreturn main();"
|
| 494 |
+
},
|
| 495 |
+
"type": "n8n-nodes-base.code",
|
| 496 |
+
"typeVersion": 2,
|
| 497 |
+
"position": [
|
| 498 |
+
464,
|
| 499 |
+
304
|
| 500 |
+
],
|
| 501 |
+
"id": "5d7dc4bc-9f60-4e83-878f-bf47a16b0209",
|
| 502 |
+
"name": "Boost View 川普專題"
|
| 503 |
+
},
|
| 504 |
+
{
|
| 505 |
+
"parameters": {
|
| 506 |
+
"authentication": "webhook",
|
| 507 |
+
"content": "={{ $json.message }}",
|
| 508 |
+
"options": {}
|
| 509 |
+
},
|
| 510 |
+
"type": "n8n-nodes-base.discord",
|
| 511 |
+
"typeVersion": 2,
|
| 512 |
+
"position": [
|
| 513 |
+
1184,
|
| 514 |
+
-16
|
| 515 |
+
],
|
| 516 |
+
"id": "1ef12db6-b1ed-4689-a0a3-da6c067f254b",
|
| 517 |
+
"name": "Notify Discord",
|
| 518 |
+
"webhookId": "a2cf639d-4a4a-4391-b665-269703327916",
|
| 519 |
+
"credentials": {
|
| 520 |
+
"discordWebhookApi": {
|
| 521 |
+
"id": "PgAS3Za8Re1XFY1H",
|
| 522 |
+
"name": "Discord Webhook account"
|
| 523 |
+
}
|
| 524 |
+
}
|
| 525 |
+
},
|
| 526 |
+
{
|
| 527 |
+
"parameters": {
|
| 528 |
+
"mode": "combine",
|
| 529 |
+
"combineBy": "combineByPosition",
|
| 530 |
+
"options": {}
|
| 531 |
+
},
|
| 532 |
+
"type": "n8n-nodes-base.merge",
|
| 533 |
+
"typeVersion": 3.2,
|
| 534 |
+
"position": [
|
| 535 |
+
752,
|
| 536 |
+
144
|
| 537 |
+
],
|
| 538 |
+
"id": "78253ec2-aa76-406d-93b0-bc34e3727c22",
|
| 539 |
+
"name": "Merge"
|
| 540 |
+
},
|
| 541 |
+
{
|
| 542 |
+
"parameters": {
|
| 543 |
+
"method": "POST",
|
| 544 |
+
"url": "https://api.line.me/v2/bot/message/push",
|
| 545 |
+
"authentication": "genericCredentialType",
|
| 546 |
+
"genericAuthType": "httpBearerAuth",
|
| 547 |
+
"sendBody": true,
|
| 548 |
+
"specifyBody": "json",
|
| 549 |
+
"jsonBody": "={{\n JSON.stringify({\n \"to\": \"C07043bf7944b51ee170ec5f4092e9b54\",\n \"messages\": [\n {\n \"sender\": {\n \"name\": \"豐雲學堂\",\n \"iconUrl\": \"https://richclub.azureedge.net/public/android-icon-144x144.png\"\n },\n \"type\": \"flex\",\n \"altText\": \"本周深談總經及川普專題的執行已結束,請察看結果。\",\n \"contents\": {\n \"type\": \"carousel\",\n \"contents\": [\n {\n \"type\": \"bubble\",\n \"hero\": {\n \"type\": \"image\",\n \"url\": `https://richclub.azureedge.net/article/${$('Build URL 深談總經').first().json.articleId}/poster.jpg`,\n \"size\": \"full\",\n \"aspectRatio\": \"20:13\",\n \"aspectMode\": \"cover\"\n },\n \"body\": {\n \"type\": \"box\",\n \"layout\": \"vertical\",\n \"contents\": [\n { \"type\": \"text\", \"text\": \"深談總經\", \"weight\": \"bold\", \"size\": \"xl\", \"color\": \"#1DB446\" },\n { \"type\": \"text\", \"text\": $('Build URL 深談總經').first().json.title, \"size\": \"xs\", \"color\": \"#8c8c8c\", \"wrap\": true, \"margin\": \"md\" },\n { \"type\": \"separator\", \"margin\": \"lg\" },\n {\n \"type\": \"box\",\n \"layout\": \"vertical\",\n \"margin\": \"lg\",\n \"spacing\": \"sm\",\n \"contents\": [\n { \"type\": \"box\", \"layout\": \"baseline\", \"spacing\": \"sm\", \"contents\": [\n { \"type\": \"text\", \"text\": \"執行/成功\", \"color\": \"#aaaaaa\", \"size\": \"sm\", \"flex\": 2 },\n { \"type\": \"text\", \"text\": `${$node[\"Build Notification\"].json.macroResult.totalToRun} / ${$node[\"Build Notification\"].json.macroResult.successCount}`, \"wrap\": true, \"color\": \"#666666\", \"size\": \"sm\", \"flex\": 4 }\n ]},\n { \"type\": \"box\", \"layout\": \"baseline\", \"spacing\": \"sm\", \"contents\": [\n { \"type\": \"text\", \"text\": \"成功率\", \"color\": \"#aaaaaa\", \"size\": \"sm\", \"flex\": 2 },\n { \"type\": \"text\", \"text\": $node[\"Build Notification\"].json.macroResult.successRate, \"wrap\": true, \"color\": \"#1DB446\", \"size\": \"sm\", \"weight\": \"bold\", \"flex\": 4 }\n ]},\n { \"type\": \"box\", \"layout\": \"baseline\", \"spacing\": \"sm\", \"contents\": [\n { \"type\": \"text\", \"text\": \"最終觀看\", \"color\": \"#aaaaaa\", \"size\": \"sm\", \"flex\": 2 },\n { \"type\": \"text\", \"text\": String($node[\"Build Notification\"].json.macroResult.newViewCount), \"wrap\": true, \"color\": \"#666666\", \"size\": \"sm\", \"flex\": 4 }\n ]}\n ]\n }\n ]\n },\n \"footer\": {\n \"type\": \"box\",\n \"layout\": \"vertical\",\n \"spacing\": \"sm\",\n \"contents\": [\n { \"type\": \"button\", \"style\": \"link\", \"height\": \"sm\", \"action\": { \"type\": \"uri\", \"label\": \"查看文章\", \"uri\": $('Build URL 深談總經').first().json.url } },\n { \"type\": \"text\", \"text\": `完成於: ${new Date().toLocaleString('zh-TW', { timeZone: 'Asia/Taipei' })}`, \"size\": \"xxs\", \"color\": \"#cccccc\", \"align\": \"center\" }\n ]\n }\n },\n {\n \"type\": \"bubble\",\n \"hero\": {\n \"type\": \"image\",\n \"url\": `https://richclub.azureedge.net/article/${$('Build URL 川普專題').first().json.articleId}/poster.jpg`,\n \"size\": \"full\",\n \"aspectRatio\": \"20:13\",\n \"aspectMode\": \"cover\"\n },\n \"body\": {\n \"type\": \"box\",\n \"layout\": \"vertical\",\n \"contents\": [\n { \"type\": \"text\", \"text\": \"川普專題\", \"weight\": \"bold\", \"size\": \"xl\", \"color\": \"#0055ff\" },\n { \"type\": \"text\", \"text\": $('Build URL 川普專題').first().json.title, \"size\": \"xs\", \"color\": \"#8c8c8c\", \"wrap\": true, \"margin\": \"md\" },\n { \"type\": \"separator\", \"margin\": \"lg\" },\n {\n \"type\": \"box\",\n \"layout\": \"vertical\",\n \"margin\": \"lg\",\n \"spacing\": \"sm\",\n \"contents\": [\n { \"type\": \"box\", \"layout\": \"baseline\", \"spacing\": \"sm\", \"contents\": [\n { \"type\": \"text\", \"text\": \"執行/成功\", \"color\": \"#aaaaaa\", \"size\": \"sm\", \"flex\": 2 },\n { \"type\": \"text\", \"text\": `${$node[\"Build Notification\"].json.trumpResult.totalRequests} / ${$node[\"Build Notification\"].json.successCount}`, \"wrap\": true, \"color\": \"#666666\", \"size\": \"sm\", \"flex\": 4 }\n ]},\n { \"type\": \"box\", \"layout\": \"baseline\", \"spacing\": \"sm\", \"contents\": [\n { \"type\": \"text\", \"text\": \"成功率\", \"color\": \"#aaaaaa\", \"size\": \"sm\", \"flex\": 2 },\n { \"type\": \"text\", \"text\": $node[\"Build Notification\"].json.trumpResult.successRate, \"wrap\": true, \"color\": \"#1DB446\", \"size\": \"sm\", \"weight\": \"bold\", \"flex\": 4 }\n ]},\n { \"type\": \"box\", \"layout\": \"baseline\", \"spacing\": \"sm\", \"contents\": [\n { \"type\": \"text\", \"text\": \"最終觀看\", \"color\": \"#aaaaaa\", \"size\": \"sm\", \"flex\": 2 },\n { \"type\": \"text\", \"text\": String($node[\"Build Notification\"].json.trumpResult.newViewCount), \"wrap\": true, \"color\": \"#666666\", \"size\": \"sm\", \"flex\": 4 }\n ]}\n ]\n }\n ]\n },\n \"footer\": {\n \"type\": \"box\",\n \"layout\": \"vertical\",\n \"spacing\": \"sm\",\n \"contents\": [\n { \"type\": \"button\", \"style\": \"link\", \"height\": \"sm\", \"action\": { \"type\": \"uri\", \"label\": \"查看文章\", \"uri\": $('Build URL 川普專題').first().json.url } },\n { \"type\": \"text\", \"text\": `完成於: ${new Date().toLocaleString('zh-TW', { timeZone: 'Asia/Taipei' })}`, \"size\": \"xxs\", \"color\": \"#cccccc\", \"align\": \"center\" }\n ]\n }\n }\n ]\n }\n }\n ]\n })\n}}",
|
| 550 |
+
"options": {}
|
| 551 |
+
},
|
| 552 |
+
"type": "n8n-nodes-base.httpRequest",
|
| 553 |
+
"typeVersion": 4.3,
|
| 554 |
+
"position": [
|
| 555 |
+
1184,
|
| 556 |
+
304
|
| 557 |
+
],
|
| 558 |
+
"id": "8efd2189-96f6-49b4-94f3-89a90ca64ef2",
|
| 559 |
+
"name": "Notify Line",
|
| 560 |
+
"credentials": {
|
| 561 |
+
"httpBearerAuth": {
|
| 562 |
+
"id": "iJvKQKPJqm4Bdr83",
|
| 563 |
+
"name": "Bearer Auth account"
|
| 564 |
+
}
|
| 565 |
+
}
|
| 566 |
+
}
|
| 567 |
+
],
|
| 568 |
+
"connections": {
|
| 569 |
+
"Weekly Schedule": {
|
| 570 |
+
"main": [
|
| 571 |
+
[
|
| 572 |
+
{
|
| 573 |
+
"node": "Fetch 深談總經",
|
| 574 |
+
"type": "main",
|
| 575 |
+
"index": 0
|
| 576 |
+
},
|
| 577 |
+
{
|
| 578 |
+
"node": "Fetch 川普專題",
|
| 579 |
+
"type": "main",
|
| 580 |
+
"index": 0
|
| 581 |
+
}
|
| 582 |
+
]
|
| 583 |
+
]
|
| 584 |
+
},
|
| 585 |
+
"Fetch 深談總經": {
|
| 586 |
+
"main": [
|
| 587 |
+
[
|
| 588 |
+
{
|
| 589 |
+
"node": "Build URL 深談總經",
|
| 590 |
+
"type": "main",
|
| 591 |
+
"index": 0
|
| 592 |
+
}
|
| 593 |
+
]
|
| 594 |
+
]
|
| 595 |
+
},
|
| 596 |
+
"Fetch 川普專題": {
|
| 597 |
+
"main": [
|
| 598 |
+
[
|
| 599 |
+
{
|
| 600 |
+
"node": "Build URL 川普專題",
|
| 601 |
+
"type": "main",
|
| 602 |
+
"index": 0
|
| 603 |
+
}
|
| 604 |
+
]
|
| 605 |
+
]
|
| 606 |
+
},
|
| 607 |
+
"Build URL 深談總經": {
|
| 608 |
+
"main": [
|
| 609 |
+
[
|
| 610 |
+
{
|
| 611 |
+
"node": "Boost View 深談總經",
|
| 612 |
+
"type": "main",
|
| 613 |
+
"index": 0
|
| 614 |
+
}
|
| 615 |
+
]
|
| 616 |
+
]
|
| 617 |
+
},
|
| 618 |
+
"Build URL 川普專題": {
|
| 619 |
+
"main": [
|
| 620 |
+
[
|
| 621 |
+
{
|
| 622 |
+
"node": "Boost View 川普專題",
|
| 623 |
+
"type": "main",
|
| 624 |
+
"index": 0
|
| 625 |
+
}
|
| 626 |
+
]
|
| 627 |
+
]
|
| 628 |
+
},
|
| 629 |
+
"Build Notification": {
|
| 630 |
+
"main": [
|
| 631 |
+
[
|
| 632 |
+
{
|
| 633 |
+
"node": "Notify Discord",
|
| 634 |
+
"type": "main",
|
| 635 |
+
"index": 0
|
| 636 |
+
},
|
| 637 |
+
{
|
| 638 |
+
"node": "Notify Line",
|
| 639 |
+
"type": "main",
|
| 640 |
+
"index": 0
|
| 641 |
+
}
|
| 642 |
+
]
|
| 643 |
+
]
|
| 644 |
+
},
|
| 645 |
+
"Boost View 深談總經": {
|
| 646 |
+
"main": [
|
| 647 |
+
[
|
| 648 |
+
{
|
| 649 |
+
"node": "Merge",
|
| 650 |
+
"type": "main",
|
| 651 |
+
"index": 0
|
| 652 |
+
}
|
| 653 |
+
]
|
| 654 |
+
]
|
| 655 |
+
},
|
| 656 |
+
"Boost View 川普專題": {
|
| 657 |
+
"main": [
|
| 658 |
+
[
|
| 659 |
+
{
|
| 660 |
+
"node": "Merge",
|
| 661 |
+
"type": "main",
|
| 662 |
+
"index": 1
|
| 663 |
+
}
|
| 664 |
+
]
|
| 665 |
+
]
|
| 666 |
+
},
|
| 667 |
+
"Notify Discord": {
|
| 668 |
+
"main": [
|
| 669 |
+
[]
|
| 670 |
+
]
|
| 671 |
+
},
|
| 672 |
+
"Merge": {
|
| 673 |
+
"main": [
|
| 674 |
+
[
|
| 675 |
+
{
|
| 676 |
+
"node": "Build Notification",
|
| 677 |
+
"type": "main",
|
| 678 |
+
"index": 0
|
| 679 |
+
}
|
| 680 |
+
]
|
| 681 |
+
]
|
| 682 |
+
}
|
| 683 |
+
},
|
| 684 |
+
"authors": "Yuchen Lin",
|
| 685 |
+
"name": "Version b6375c65",
|
| 686 |
+
"description": "Enable Line Flex Card",
|
| 687 |
+
"autosaved": false
|
| 688 |
+
},
|
| 689 |
+
"tags": []
|
| 690 |
+
}
|