<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>豆包 &#8211; 慢城市快生活</title>
	<atom:link href="http://www.gwren.com/tag/%E8%B1%86%E5%8C%85/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.gwren.com</link>
	<description></description>
	<lastBuildDate>Tue, 11 Feb 2025 07:10:36 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.2</generator>
	<item>
		<title>找豆包写了个网页另存为docx文件的篡改猴 (Tampermonkey) 脚本，然后又叫她把求助过程写了篇文章</title>
		<link>http://www.gwren.com/2025/02/%e6%89%be%e8%b1%86%e5%8c%85%e5%86%99%e4%ba%86%e4%b8%aa%e7%bd%91%e9%a1%b5%e5%8f%a6%e5%ad%98%e4%b8%badocx%e6%96%87%e4%bb%b6%e7%9a%84%e7%af%a1%e6%94%b9%e7%8c%b4-tampermonkey-%e8%84%9a%e6%9c%ac/</link>
					<comments>http://www.gwren.com/2025/02/%e6%89%be%e8%b1%86%e5%8c%85%e5%86%99%e4%ba%86%e4%b8%aa%e7%bd%91%e9%a1%b5%e5%8f%a6%e5%ad%98%e4%b8%badocx%e6%96%87%e4%bb%b6%e7%9a%84%e7%af%a1%e6%94%b9%e7%8c%b4-tampermonkey-%e8%84%9a%e6%9c%ac/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Tue, 11 Feb 2025 07:10:36 +0000</pubDate>
				<category><![CDATA[AI使用]]></category>
		<category><![CDATA[AI]]></category>
		<category><![CDATA[编程]]></category>
		<category><![CDATA[脚本]]></category>
		<category><![CDATA[豆包]]></category>
		<guid isPermaLink="false">http://www.gwren.com/?p=226</guid>

					<description><![CDATA[🤩用豆包轻松搞定 Tampermonkey 脚本！ 🤩用豆包轻松搞定 Tampermonkey 脚本！ 宝子们&#8230; <a href="http://www.gwren.com/2025/02/%e6%89%be%e8%b1%86%e5%8c%85%e5%86%99%e4%ba%86%e4%b8%aa%e7%bd%91%e9%a1%b5%e5%8f%a6%e5%ad%98%e4%b8%badocx%e6%96%87%e4%bb%b6%e7%9a%84%e7%af%a1%e6%94%b9%e7%8c%b4-tampermonkey-%e8%84%9a%e6%9c%ac/" class="more-link">继续阅读 <span class="screen-reader-text">找豆包写了个网页另存为docx文件的篡改猴 (Tampermonkey) 脚本，然后又叫她把求助过程写了篇文章</span></a>]]></description>
										<content:encoded><![CDATA[
<p><!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><img src="https://s.w.org/images/core/emoji/15.0.3/72x72/1f929.png" alt="🤩" class="wp-smiley" style="height: 1em; max-height: 1em;" />用豆包轻松搞定 Tampermonkey 脚本！</title>
</head>
<body>

    <h1><img src="https://s.w.org/images/core/emoji/15.0.3/72x72/1f929.png" alt="🤩" class="wp-smiley" style="height: 1em; max-height: 1em;" />用豆包轻松搞定 Tampermonkey 脚本！</h1>

    <p>宝子们<img src="https://s.w.org/images/core/emoji/15.0.3/72x72/1f44b.png" alt="👋" class="wp-smiley" style="height: 1em; max-height: 1em;" />，今天来给大家分享一下我是如何借助豆包编程助手编写 Tampermonkey 脚本的，学会了之后真的能让上网变得超有趣又高效<img src="https://s.w.org/images/core/emoji/15.0.3/72x72/1f44f.png" alt="👏" class="wp-smiley" style="height: 1em; max-height: 1em;" />！</p>

    <h2><img src="https://s.w.org/images/core/emoji/15.0.3/72x72/1f388.png" alt="🎈" class="wp-smiley" style="height: 1em; max-height: 1em;" />什么是 Tampermonkey 脚本？</h2>
    <p>Tampermonkey 是一款超强大的浏览器扩展，它可以让我们通过编写脚本来自定义网页的功能和外观。比如说，你可以去除网页广告、自动填充表单、批量下载图片等等<img src="https://s.w.org/images/core/emoji/15.0.3/72x72/1f9d0.png" alt="🧐" class="wp-smiley" style="height: 1em; max-height: 1em;" />。有了它，上网就像开了挂一样！</p>

    <h2><img src="https://s.w.org/images/core/emoji/15.0.3/72x72/1f9d1-200d-1f4bb.png" alt="🧑‍💻" class="wp-smiley" style="height: 1em; max-height: 1em;" />准备工作</h2>
    <ol>
        <li>安装 Tampermonkey 扩展：在你的浏览器扩展商店（像 Chrome、Edge 等）里搜索“Tampermonkey”，然后点击安装就好啦。安装完成后，浏览器右上角会出现一个小猴子图标<img src="https://s.w.org/images/core/emoji/15.0.3/72x72/1f435.png" alt="🐵" class="wp-smiley" style="height: 1em; max-height: 1em;" />。</li>
        <li>打开豆包编程助手：就是咱们超厉害的豆包啦，它能帮你快速生成脚本代码<img src="https://s.w.org/images/core/emoji/15.0.3/72x72/1f60e.png" alt="😎" class="wp-smiley" style="height: 1em; max-height: 1em;" />。</li>
    </ol>

    <h2><img src="https://s.w.org/images/core/emoji/15.0.3/72x72/1f680.png" alt="🚀" class="wp-smiley" style="height: 1em; max-height: 1em;" />开始编写脚本</h2>
    <p>我以编写一个“网页另存为 Word 文档”的脚本为例，给大家详细说说步骤<img src="https://s.w.org/images/core/emoji/15.0.3/72x72/1f447.png" alt="👇" class="wp-smiley" style="height: 1em; max-height: 1em;" />。</p>

    <h3>1. 告诉豆包需求</h3>
    <p>在和豆包的对话框里，清晰地描述你想要实现的功能。比如我当时就说：“帮我编写一段网页另存为 word 文档的 Tampermonkey 代码，要求保留主页面的所有元素。要求在页面顶端增加一个另存按钮，另外自动命名为网页名称”。把需求说得越详细，豆包给出的代码就越符合你的心意<img src="https://s.w.org/images/core/emoji/15.0.3/72x72/1f61c.png" alt="😜" class="wp-smiley" style="height: 1em; max-height: 1em;" />。</p>

    <h3>2. 获取代码</h3>
    <p>豆包很快就会生成对应的代码，像这样：</p>
    <pre><code>
// ==UserScript==
// @name         Save Web Page as Word
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Add a button to save the web page as a Word document.
// @author       You
// @match        *://*/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // 创建一个按钮元素
    const saveButton = document.createElement('button');
    saveButton.textContent = '另存为 Word';
    saveButton.style.position = 'fixed';
    saveButton.style.top = '10px';
    saveButton.style.left = '10px';
    saveButton.style.zIndex = '9999';

    // 将按钮添加到页面
    document.body.appendChild(saveButton);

    // 为按钮添加点击事件监听器
    saveButton.addEventListener('click', function() {
        // 获取网页标题
        const pageTitle = document.title;

        // 获取页面的 HTML 内容
        const htmlContent = document.documentElement.outerHTML;

        // 创建一个 Blob 对象，将 HTML 内容转换为二进制数据
        const blob = new Blob([htmlContent], { type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' });

        // 创建一个 URL 对象
        const url = URL.createObjectURL(blob);

        // 创建一个链接元素
        const link = document.createElement('a');
        link.href = url;
        link.download = `${pageTitle}.docx`;

        // 模拟点击链接以下载文件
        link.click();

        // 释放 URL 对象
        URL.revokeObjectURL(url);
    });
})();
    </code></pre>

    <h3>3. 创建并粘贴脚本</h3>
    <ol>
        <li>点击浏览器右上角的 Tampermonkey 小猴子图标，选择“创建一个新脚本”。</li>
        <li>把豆包给的代码复制粘贴到 Tampermonkey 的脚本编辑器里。</li>
        <li>点击编辑器左上角的“保存”按钮<img src="https://s.w.org/images/core/emoji/15.0.3/72x72/1f4be.png" alt="💾" class="wp-smiley" style="height: 1em; max-height: 1em;" />。</li>
    </ol>

    <h3>4. 测试脚本</h3>
    <p>打开任意一个网页，你会发现页面顶端出现了“另存为 Word”的按钮。点击这个按钮，网页就会保存为 Word 文档，文件名就是网页的标题<img src="https://s.w.org/images/core/emoji/15.0.3/72x72/1f60f.png" alt="😏" class="wp-smiley" style="height: 1em; max-height: 1em;" />。</p>

    <h2><img src="https://s.w.org/images/core/emoji/15.0.3/72x72/1f4a1.png" alt="💡" class="wp-smiley" style="height: 1em; max-height: 1em;" />小技巧和注意事项</h2>
    <ul>
        <li>如果代码运行有问题，仔细检查一下需求描述是否准确，或者跟豆包说清楚问题，让它帮你修改代码。</li>
        <li>不同的网页可能有不同的结构和安全策略，有些脚本可能在某些网页上无法正常工作，这时候就需要进一步调整代码啦。</li>
    </ul>

    <p>宝子们，赶紧动手试试用豆包编写 Tampermonkey 脚本吧，让你的上网体验更上一层楼<img src="https://s.w.org/images/core/emoji/15.0.3/72x72/1f970.png" alt="🥰" class="wp-smiley" style="height: 1em; max-height: 1em;" />！</p>

    <p>#Tampermonkey #脚本编写 #豆包编程助手 #上网技巧</p>

</body>
</html></p>
]]></content:encoded>
					
					<wfw:commentRss>http://www.gwren.com/2025/02/%e6%89%be%e8%b1%86%e5%8c%85%e5%86%99%e4%ba%86%e4%b8%aa%e7%bd%91%e9%a1%b5%e5%8f%a6%e5%ad%98%e4%b8%badocx%e6%96%87%e4%bb%b6%e7%9a%84%e7%af%a1%e6%94%b9%e7%8c%b4-tampermonkey-%e8%84%9a%e6%9c%ac/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
