javascript-trap.html - en to zh_CN translation catalogue (47 entries)

note: type: Content of: <title>
en: The JavaScript Trap - GNU Project - Free Software Foundation
zh_CN: JavaScript 的陷井 - GNU 工程 - 自由软件基金会

note: type: Content of: <div><h2>
en: The JavaScript Trap
zh_CN: JavaScript 的陷阱

note: type: Content of: <div><address>
en: by <a href="https://www.stallman.org/">Richard Stallman</a>
zh_CN: <a href="https://www.stallman.org/">理查德·斯托曼</a> 著

note: type: Content of: <div><div><p>
en: There are two kinds of moral wrongs a web page can do.  This page describes the wrong of sending nonfree programs to run in your computer.  There is also the wrong we call SaaSS, &ldquo;Service as a Software Substitute&rdquo; where the page invites you to <a href="/philosophy/who-does-that-server-really-serve.html">send your data</a> so it can do computing on it in the server&mdash;computing which is unjust because you have no control over what computing is done.
zh_CN: 网页可以有两种道德错误。本页描述的是其中一种：网页向电脑发送并运行非自由软件。另外一种错误我们称之为 SaaSS——&ldquo;服务代替软件&rdquo;——网页请你 <a href="/philosophy/who-does-that-server-really-serve.html">把数据发过去</a>，这样它就可以在服务器上做计算&mdash;&mdash;这种计算是不公正的，因为你没有对计算的控制权。

note: type: Content of: <div><p>
en: <strong>You may be running nonfree programs on your computer every day without realizing it&mdash;through your web browser.</strong>
zh_CN: <strong>你可能每天都在自己的电脑上运行非自由软件却毫不知情&mdash;&mdash;通过使用你的浏览器。</strong>

note: type: Content of: <div><div><p>
en: Webmasters: there are <a href="/software/librejs/free-your-javascript.html">several ways</a> to indicate the license of JavaScript programs in a web site.
zh_CN: 网络管理员：有<a href="/software/librejs/free-your-javascript.html">好几种方法</a>可以指示网站的JavaScript程序的许可证。

note: type: Content of: <div><p>
en: In the free software community, the idea that <a href="/philosophy/free-software-even-more-important.html"> any nonfree program mistreats its users</a> is familiar.  Some of us defend our freedom by rejecting all proprietary software on our computers.  Many others recognize nonfreeness as a strike against the program.
zh_CN: 在自由软件社区，<a href="/philosophy/free-software-even-more-important.html">非自由软件会侵害其用户</a>的概念大家都很熟悉。有些人会拒绝在电脑上使用任何专有软件，以此来捍卫自己的自由。还有许多人意识到非自由并拒绝那些程序。

note: type: Content of: <div><p>
en: Many users are aware that this issue applies to the plug-ins that browsers offer to install, since they can be free or nonfree.  But browsers run other nonfree programs which they don't ask you about, or even tell you about&mdash;programs that web pages contain or link to.  These programs are most often written in JavaScript, though other languages are also used.
zh_CN: 许多用户知道浏览器要求安装的插件有此问题，因为它们可能是自由软件，也可能是非自由软件。但是浏览器也会运行不要求你许可的其他非自由软件，甚至也不告诉你&mdash;&mdash;网页带有或链接了哪些程序。这些程序多数是用JavaScript编写的，虽然其他语言也是可以的。

note: type: Content of: <div><p>
en: JavaScript (officially called ECMAScript, but few use that name)  was once used for minor frills in web pages, such as cute but inessential navigation and display features.  It was acceptable to consider these as mere extensions of HTML markup, rather than as true software, and disregard the issue.
zh_CN: JavaScript（正式名称是ECMAScript，但是很少有人用了）曾经用于不重要的网页装饰，比如可爱但是并不重要的导航和显示功能。可以认为这些只是HTML标记语言的扩展，而不是真正的软件，这样就可以忽略它的问题。

note: type: Content of: <div><p>
en: Some sites still use JavaScript that way, but many use it for major programs that do large jobs.  For instance, Google Docs tries to install into your browser a JavaScript program which measures half a megabyte, in a compacted form that we could call Obfuscript.  This compacted form is made from the source code, by deleting the extra spaces that make the code readable and the explanatory remarks that make it comprehensible, and replacing each meaningful name in the code with an arbitrary short name so we can't tell what it is supposed to mean.
zh_CN: 一些网站仍然这样使用JavaScript，但是有一些网站用它作为完成任务的主要程序。例如，Google Docs会尝试在你的电脑里下载大约500k字节的JavaScript程序，该程序使用一种我们称之为模糊脚本（Obfuscript）的紧密格式。这种格式删除了源代码里有助阅读的空格和注释，并将原来有意义的方法名称替换为任意的短名称，这样人们就无法直接看出这些方法原来的意义。

note: type: Content of: <div><p>
en: Part of the <a href="/philosophy/free-sw.html">meaning of free software</a> is that users have access to the program's source code (its plan).  The source code of a program means the preferred form for programmers to modify&mdash;including helpful spacing, explanatory remarks, and meaningful names.  Compacted code is a bogus, useless substitute for source code; the real source code of these programs is not available to the users, so users cannot understand it; therefore the programs are nonfree.
zh_CN: <a href="/philosophy/free-sw.html">自由软件定义</a>的内容包含着用户可以访问程序的源代码。一个程序的源代码应该是有利于修改程序的形式&mdash;包括有利阅读的空格和分行、解释性注释和有意义的名称。这种紧密格式不是源代码，而只是毫无用处的源代码替代品；其源代码并没有提供给用户，因而用户无法了解该程序；该程序是非自由的。

note: type: Content of: <div><p>
en: In addition to being nonfree, many of these programs are <em>malware</em> because they <a href="https://github.com/w3c/fingerprinting-guidance/issues/8">snoop on the user</a>.  Even nastier, some sites use services which record <a href="https://freedom-to-tinker.com/2017/11/15/no-boundaries-exfiltration-of-personal-data-by-session-replay-scripts/">all the user's actions while looking at the page</a>.  The services supposedly &ldquo;redact&rdquo; the recordings to exclude some sensitive data that the web site shouldn't get.  But even if that works reliably, the whole purpose of these services is to give the web site other personal data that it shouldn't get.
zh_CN: 除了是非自由软件，许多这种程序是<em>恶意软件</em>，因为它们<a href="https://github.com/w3c/fingerprinting-guidance/issues/8">嗅探用户</a>。更恶劣的是，有些站点使用服务来记录<a href="https://freedom-to-tinker.com/2017/11/15/no-boundaries-exfiltration-of-personal-data-by-session-replay-scripts/">用户浏览该页面时的所有行为</a>。该服务本来应该&ldquo;修改&rdquo;记录以抹去网站不该获得的一些敏感数据。但是，即使该功能能够可靠的实施，该服务的整体目的也是给予该网站它不应该获得的个人数据。

note: type: Content of: <div><p>
en: Browsers don't normally tell you when they load JavaScript programs.  Some browsers have a way to turn off JavaScript entirely, but even if you're aware of this issue, it would take you considerable trouble to identify the nontrivial nonfree programs and block them.  However, even in the free software community most users are not aware of this issue; the browsers' silence tends to conceal it.
zh_CN: 浏览器一般不会告诉你它们什么时候会加载JavaScript程序。有些浏览器提供了完全禁用JavaScript的方法，可是即使你知道有问题，你还是需要花很多精力去确认这些非自由软件并拦截它们。然而，就连自由软件社区的大多数用户都不知道这个有问题；而浏览器的沉默也好似在掩盖这个问题。

note: type: Content of: <div><p>
en: To be clear, the language JavaScript is not inherently better or worse for users' freedom than any other language.  It is possible to release a JavaScript program as free software, by distributing the source code under a free software license.  If the program is self-contained&mdash;if its functioning and purpose are independent of the page it came in&mdash;that is fine; you can copy it to a file on your machine, modify it, and visit that file with a browser to run it.  It's even possible to package it for installation just like other free programs and invocation with a shell command.  These programs present no special moral issue different from those of C programs.
zh_CN: 澄清一下，JavaScript 语言本身和其他语言一样，并不影响用户的自由。JavaScript 程序也能发布为自由软件，使用自由软件许可证发布其源代码就行。如果该程序是自给自足的&mdash;&mdash;如果它的功能和目的独立于它所应用的网站&mdash;&mdash;这就没问题；你可以将其拷贝到你的电脑，修改它，使用浏览器加载它并运行它。你甚至可以把 JavaScript 象其他自由软件一样打包，并在命令行调用。这些程序和 C 程序一样并没有特别的道德问题。

note: type: Content of: <div><p>
en: The issue of the JavaScript trap applies when the JavaScript program comes along with a web page that users visit.  Those JavaScript programs are written to work with a particular page or site, and the page or site depends on them to function.
zh_CN: JavaScript 陷阱适用于用户访问网页时网页带有的 JavaScript 程序。这些 JavaScript 程序专门为特定网页或网站编写，这些网页或网站依赖这些程序才能工作。

note: type: Content of: <div><p>
en: Suppose you copy and modify the page's JavaScript code.  Then another problem arises: even if the program's source is available, browsers do not offer a way to run your modified version instead of the original when visiting that page or site.  The effect is comparable to tivoization, although in principle not quite so hard to overcome.
zh_CN: 假定你可以复制和修改这些 JavaScript程序。这就出现了另一个问题：即使有源程序，浏览器也无法运行你修改的版本，它只支持使用原来的版本访问该网站或网页。这个效果和 tivoization<sup><a href="#TransNote1">1</a></sup>类似，虽然从根本上不象那么难以解决。

note: type: Content of: <div><p>
en: JavaScript is not the only language web sites use for programs sent to the user.  Flash supported programming through an extended variant of JavaScript, but that is a thing of the past.  Microsoft Silverlight seems likely to create a problem similar to Flash, except worse, since Microsoft uses it as a platform for nonfree codecs.  A free replacement for Silverlight does not do the job adequately for the free world unless it normally comes with free replacement codecs.
zh_CN: JavaScript 不是网站发送到用户的程序使用的唯一语言。Flash 支持用一种扩展的 JavaScript 语言编程，不过这个已经是历史了。Silverlight 似乎也和 Flash 一样创建一些程序，可能更糟，因为微软使用它作为非自由编解码器的平台。自由的 Silverlight 替代不能为自由世界正常工作，除非它还带有自由的编解码替代。

note: type: Content of: <div><p>
en: Java applets also run in the browser, and raise similar issues.  In general, any sort of applet system poses this sort of problem.  Having a free execution environment for an applet only brings us far enough to encounter the problem.
zh_CN: Java小程序<sup><a href="#TransNote2">2</a></sup>也会在浏览器里运行，也就有同样的问题。一般来说，各种小程序系统都有这样的问题。创建一个运行小程序的自由环境仅仅是让我们能够看到这个问题。

note: type: Content of: <div><p>
en: It is theoretically possible to program in HTML and CSS, but in practice this capability is limited and inconvenient; merely to make it do something is an impressive hack.  Such programs ought to be free, but CSS is not a serious problem for users' freedom as of 2019.
zh_CN: 理论上能够使用HTML和CSS编程，但是实际上它不方便而且受限制；最多只是展示一些令人惊奇的黑客编程技巧。这些程序理应是自由的，不过CSS在2019年还不是影响用户自由的严重问题。

note: type: Content of: <div><p>
en: A strong movement has developed that calls for web sites to communicate only through formats and protocols that are free (some say &ldquo;open&rdquo;); that is to say, whose documentation is published and which anyone is free to implement.  However, the presence of JavaScript programs in web pages makes that criterion insufficient.  The JavaScript language itself, as a format, is free, and use of JavaScript in a web site is not necessarily bad.  However, as we've seen above, it can be bad&mdash;if the JavaScript program is nonfree.  When the site transmits a program to the user, it is not enough for the program to be written in a documented and unencumbered language; that program must be free, too.  &ldquo;Transmits only free programs to the user&rdquo; must become part of the criterion for an ethical web site.
zh_CN: 已经有一个强大的运动，它号召网站只使用自由（有的人叫&ldquo;开放&rdquo;）的格式和协议来通信；就是说，它们的文档应该公开，而且任何人都有自由来实现。然而，当网页带有JavaScript程序时，这个标准就不够了。JavaScript本身，作为一种格式，是自由的，而且在网站上使用JavaScript并不必然是坏事。然而，正如以上所看到的，它也不必然就是好事&mdash;&mdash;如果JavaScript程序是非自由软件。当网站将程序转移到用户，程序只是由有文档、不受限制的语言编写并不足够；该程序必须也是自由的。&ldquo;只许把自由软件转移到用户&rdquo;必须成为网站行为规范的准则。

note: type: Content of: <div><p>
en: Silently loading and running nonfree programs is one among several issues raised by &ldquo;web applications.&rdquo; The term &ldquo;web application&rdquo; was designed to disregard the fundamental distinction between software delivered to users and software running on a server.  It can refer to a specialized client program running in a browser; it can refer to specialized server software; it can refer to a specialized client program that works hand in hand with specialized server software.  The client and server sides raise different ethical issues, even if they are so closely integrated that they arguably form parts of a single program.  This article addresses only the issue of the client-side software.  We are addressing the server issue separately.
zh_CN: 不动声色地加载和运行非自由软件只是&ldquo;网络应用&rdquo;带来的诸多问题之一。&ldquo;网络应用&rdquo;这一术语就是用来抹杀用户软件和服务器软件的根本区别。它可以指运行在浏览器里的特定客户端软件；它也可以指特定的服务器软件；它还可以指和特定服务器软件紧密协作的客户端软件。客户端和服务器端有不同的道德问题，即使它们如此紧密地协作，以至于可以说它们是一个软件的不同部分。本文只讨论客户端软件的问题。我们会分开讨论服务器端的软件。

note: type: Content of: <div><p>
en: In practical terms, how can we deal with the problem of nontrivial nonfree JavaScript programs in web sites? The first step is to avoid running it.
zh_CN: 实际操作中，我们应该如何对付网站上非自由、非平凡的JavaScript程序带来的问题呢？第一步就是避免运行它。

note: type: Content of: <div><p>
en: What do we mean by &ldquo;nontrivial&rdquo;? It is a matter of degree, so this is a matter of designing a simple criterion that gives good results, rather than finding the one correct answer.
zh_CN: 什么是我们说的&ldquo;非平凡&rdquo;呢？它表示的是程度，所以它是指设计一种简明的标准来获得好的结果，而不是去寻求唯一正确的答案。

note: type: Content of: <div><p>
en: Our current criterion is to consider a JavaScript program nontrivial if any of these conditions is met:
zh_CN: 我们目前的标准认为一个JavaScript程序是非平凡的，如果它满足以下任一条件：

note: type: Content of: <div><ul><li>
en: it is referred to as an external script (from another page).
zh_CN: 该程序引用一个外部的脚本（来自另一个页面）。

note: type: Content of: <div><ul><li>
en: it declares an array more than 50 elements long.
zh_CN: 该程序声明的数组超过了50个元素。

note: type: Content of: <div><ul><li>
en: it defines a named entity (function or method) that calls anything other than a primitive.
zh_CN: 该程序定义的主体（函数或方法）会做调用基本函数以外的调用。

note: type: Content of: <div><ul><li>
en: it defines a named entity with more than three conditional constructs and loop construction.
zh_CN: 该程序定义的主体带有3个以上的条件判断或循环结构。

note: type: Content of: <div><ul><li>
en: code outside of named definitions calls anything but primitives and functions defined further up in the page.
zh_CN: 除了定义之外，页面的代码调用了该页面上间隔很远的非基本函数。

note: type: Content of: <div><ul><li>
en: code outside of named definitions contains more than three conditional constructs and loop construction, total.
zh_CN: 除了定义之外，页面代码带有3个以上的条件判断或循环结构（两个结构的总和超过3)。

note: type: Content of: <div><ul><li>
en: it calls <b>eval</b>.
zh_CN: 该程序调用了 <b>eval</b>。

note: type: Content of: <div><ul><li>
en: it does Ajax calls.
zh_CN: 该程序有 Ajax 调用。

note: type: Content of: <div><ul><li>
en: it uses bracket notation for dynamic object property access, which looks like <b><em>object</em>[<em>property</em>]</b>.
zh_CN: 该程序使用带有方括号形式的动态对象属性访问，就像<b><em>object</em>[<em>property</em>]</b>这样。

note: type: Content of: <div><ul><li>
en: it alters the DOM.
zh_CN: 该程序修改了 DOM。

note: type: Content of: <div><ul><li>
en: it uses dynamic JavaScript constructs that are difficult to analyze without interpreting the program, or is loaded along with scripts that use such constructs.  Specifically, using any other construct than a string literal with certain methods (<b>Obj.write</b>, <b>Obj.createElement</b>, and others).
zh_CN: 该程序要么使用动态JavaScript结构，这些结构在不了解该程序的情况下很难分析，要么该程序和使用这些结构的脚本一起加载。具体情况是程序使用除了诸如带有方法（<b>Obj.write</b>, <b>Obj.createElement</b>等）之外的字符串字面量。

note: type: Content of: <div><p>
en: How do we tell whether the JavaScript code is free? In a <a href="/licenses/javascript-labels.html">separate article</a>, we propose a method by which a nontrivial JavaScript program in a web page can state the URL where its source code is located, and can state its license too, using stylized comments.
zh_CN: 我们如何判别JavaScript代码是否是自由的？在<a href="/licenses/javascript-labels.html">另一篇文章</a>中，我们提议了一种方法，它指出网页带有的非平凡JavaScript程序可以使用风格化的注释来表达获得其源代码的URL，也可以表达其许可证。

note: type: Content of: <div><p>
en: Finally, we need to change free browsers to detect and block nontrivial nonfree JavaScript in web pages.  The program <a href="/software/librejs/">LibreJS</a> detects nonfree, nontrivial JavaScript in pages you visit, and blocks it.  LibreJS is included in IceCat, and available as an add-on for Firefox.
zh_CN: 最后，我们需要修改自由的浏览器，使它们可以探测并拦截网页上非平凡、非自由的JavaScript。<a href="/software/librejs/">LibreJS</a>程序就可以探测到你访问的网页上的非自由、非平凡的JavaScript，并拦截之。LibreJS包含在IceCat浏览器中，也可以作为Firefox的附加组件。

note: type: Content of: <div><p>
en: Browser users also need a convenient facility to specify JavaScript code to use <em>instead</em> of the JavaScript in a certain page.  (The specified code might be total replacement, or a modified version of the free JavaScript program in that page.)  Greasemonkey comes close to being able to do this, but not quite, since it doesn't guarantee to modify the JavaScript code in a page before that program starts to execute.  Using a local proxy works, but is too inconvenient now to be a real solution.  We need to construct a solution that is reliable and convenient, as well as sites for sharing changes.  The GNU Project would like to recommend sites which are dedicated to free changes only.
zh_CN: 浏览器用户还需要方便的工具来指定需要使用的JavaScript代码，<em>而不是</em>使用网页上的JavaScript代码。（指定的代码可以是完全的替代，也可以是页面上的自由JavaScript程序的修改版。）Greasemonkey已经快能够做到这一点，但是还没有，因为它不能保证在页面上的JavaScript程序运行之前就做出修改。使用本地的代理可以工作，但是作为真正的解决方案还是太不方便。我们需要构建一个可靠和方便的解决方案，也要构建一个分享修改方法的网站。GNU工程愿意推荐那些只致力于分享自由修改方法的网站。

note: type: Content of: <div><p>
en: These features will make it possible for a JavaScript program included in a web page to be free in a real and practical sense.  JavaScript will no longer be a particular obstacle to our freedom&mdash;no more than C and Java are now.  We will be able to reject and even replace the nonfree nontrivial JavaScript programs, just as we reject and replace nonfree packages that are offered for installation in the usual way.  Our campaign for web sites to free their JavaScript can then begin.
zh_CN: 这些措施使网页带有的JavaScript程序变成实际和真正意义上的自由软件成为可能。JavaScript就不再是阻碍我们自由的特别障碍&mdash;就象现在的C和Java那样。我们将来能够拒绝、甚至替换掉非自由和非平凡的JavaScript程序，就像我们拒绝和替换那些以通常形式安装的非自由软件包一样。那时，我们就能够开始让网站提供自由JavaScript程序的活动了。

note: type: Content of: <div><p>
en: In the mean time, there's one case where it is acceptable to run a nonfree JavaScript program: to send a complaint to the website operators saying they should free or remove the JavaScript code in the site.  Please don't hesitate to enable JavaScript temporarily to do that&mdash;but remember to disable it again afterwards.
zh_CN: 与此同时，在一种情形下运行非自由JavaScript程序是可以接受的：使用它来向网站操作员抱怨该网站应该移除JavaScript代码或者使它自由。请不要犹豫，你可以暂时启用JavaScript做这件事&mdash;之后别忘了再禁用它就好。

note: type: Content of: <div><p>
en: <strong>Acknowledgements:</strong> I thank <a href="/people/people.html#mattlee">Matt Lee</a> and <a href="https://johnresig.com/">John Resig</a> for their help in defining our proposed criterion, and David Parunakian for bringing the problem to my attention.
zh_CN: <strong>致谢：</strong>我感谢 <a href="/people/people.html#mattlee">Matt Lee</a> 和 <a href="https://ejohn.org">John Resig</a>，他们帮助我们定义了我们提议的标准，还感谢 David Parunakian 提醒我关注此问题。

note: TRANSLATORS: Use space (SPC) as msgstr if you don't have notes. type: Content of: <div>
en: *GNUN-SLOT: TRANSLATOR'S NOTES*
zh_CN: <h3>译注</h3>
    <ol>
    <li id="TransNote1">tivoization，是一种电脑工具，它包含在GPL软件内但你却不能修改它，因为一旦发现软件遭到修改它就会自动关闭。</li>
    <li id="TransNote2">applet，是一种小程序，可以在特定的环境下独立运行。</li>
    </ol>

note: type: Content of: <div><div><p>
en: Please send general FSF &amp; GNU inquiries to <a href="mailto:gnu@gnu.org">&lt;gnu@gnu.org&gt;</a>.  There are also <a href="/contact/">other ways to contact</a> the FSF.  Broken links and other corrections or suggestions can be sent to <a href="mailto:webmasters@gnu.org">&lt;webmasters@gnu.org&gt;</a>.
zh_CN: 请将有关自由软件基金会（FSF）&amp;GNU的一般性问题发送到<a href="mailto:gnu@gnu.org">&lt;gnu@gnu.org&gt;</a>。也可以通过<a href="/contact/">其他联系方法</a>联系自由软件基金会(FSF)。有关失效链接或其他错误和建议，请发送邮件到<a href="mailto:webmasters@gnu.org">&lt;webmasters@gnu.org&gt;</a>。

note: TRANSLATORS: Ignore the original text in this paragraph, replace it with the translation of these two: We work hard and do our best to provide accurate, good quality translations.  However, we are not exempt from imperfection. Please send your comments and general suggestions in this regard to <a hr
en: Please see the <a href="/server/standards/README.translations.html">Translations README</a> for information on coordinating and contributing translations of this article.
zh_CN: 我们尽最大努力来提供精准和高质量的翻译，但难免会存在错误和不足。如果您在这方面有评论或一般性的建议，请发送至 <a href="mailto:web-translators@gnu.org">&lt;web-translators@gnu.org&gt;</a>。</p><p>关于进行协调与提交翻译的更多信息参见 <a href="/server/standards/README.translations.html">《译者指南》</a>。

note: type: Content of: <div><p>
en: This page is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nd/4.0/">Creative Commons Attribution-NoDerivatives 4.0 International License</a>.
zh_CN: 本页面使用<a rel="license" href="http://creativecommons.org/licenses/by-nd/4.0/">Creative Commons Attribution-NoDerivatives 4.0 International License</a>授权。

note: TRANSLATORS: Use space (SPC) as msgstr if you don't want credits. type: Content of: <div><div>
en: *GNUN-SLOT: TRANSLATOR'S CREDITS*
zh_CN: <b>翻译团队</b>：<a rel="team" href="https://savannah.gnu.org/projects/www-zh-cn/">&lt;CTT&gt;</a>，2017-2019，2021，2023。

note: timestamp start type: Content of: <div><p>
en: Updated:
zh_CN: 最后更新：
