{ // 获取包含Hugging Face文本的span元素 const spans = link.querySelectorAll('span.whitespace-nowrap, span.hidden.whitespace-nowrap'); spans.forEach(span => { if (span.textContent && span.textContent.trim().match(/Hugging\s*Face/i)) { span.textContent = 'AI快站'; } }); }); // 替换logo图片的alt属性 document.querySelectorAll('img[alt*="Hugging"], img[alt*="Face"]').forEach(img => { if (img.alt.match(/Hugging\s*Face/i)) { img.alt = 'AI快站 logo'; } }); } // 替换导航栏中的链接 function replaceNavigationLinks() { // 已替换标记,防止重复运行 if (window._navLinksReplaced) { return; } // 已经替换过的链接集合,防止重复替换 const replacedLinks = new Set(); // 只在导航栏区域查找和替换链接 const headerArea = document.querySelector('header') || document.querySelector('nav'); if (!headerArea) { return; } // 在导航区域内查找链接 const navLinks = headerArea.querySelectorAll('a'); navLinks.forEach(link => { // 如果已经替换过,跳过 if (replacedLinks.has(link)) return; const linkText = link.textContent.trim(); const linkHref = link.getAttribute('href') || ''; // 替换Spaces链接 - 仅替换一次 if ( (linkHref.includes('/spaces') || linkHref === '/spaces' || linkText === 'Spaces' || linkText.match(/^s*Spacess*$/i)) && linkText !== 'OCR模型免费转Markdown' && linkText !== 'OCR模型免费转Markdown' ) { link.textContent = 'OCR模型免费转Markdown'; link.href = 'https://fast360.xyz'; link.setAttribute('target', '_blank'); link.setAttribute('rel', 'noopener noreferrer'); replacedLinks.add(link); } // 删除Posts链接 else if ( (linkHref.includes('/posts') || linkHref === '/posts' || linkText === 'Posts' || linkText.match(/^s*Postss*$/i)) ) { if (link.parentNode) { link.parentNode.removeChild(link); } replacedLinks.add(link); } // 替换Docs链接 - 仅替换一次 else if ( (linkHref.includes('/docs') || linkHref === '/docs' || linkText === 'Docs' || linkText.match(/^s*Docss*$/i)) && linkText !== '模型下载攻略' ) { link.textContent = '模型下载攻略'; link.href = '/'; replacedLinks.add(link); } // 删除Enterprise链接 else if ( (linkHref.includes('/enterprise') || linkHref === '/enterprise' || linkText === 'Enterprise' || linkText.match(/^s*Enterprises*$/i)) ) { if (link.parentNode) { link.parentNode.removeChild(link); } replacedLinks.add(link); } }); // 查找可能嵌套的Spaces和Posts文本 const textNodes = []; function findTextNodes(element) { if (element.nodeType === Node.TEXT_NODE) { const text = element.textContent.trim(); if (text === 'Spaces' || text === 'Posts' || text === 'Enterprise') { textNodes.push(element); } } else { for (const child of element.childNodes) { findTextNodes(child); } } } // 只在导航区域内查找文本节点 findTextNodes(headerArea); // 替换找到的文本节点 textNodes.forEach(node => { const text = node.textContent.trim(); if (text === 'Spaces') { node.textContent = node.textContent.replace(/Spaces/g, 'OCR模型免费转Markdown'); } else if (text === 'Posts') { // 删除Posts文本节点 if (node.parentNode) { node.parentNode.removeChild(node); } } else if (text === 'Enterprise') { // 删除Enterprise文本节点 if (node.parentNode) { node.parentNode.removeChild(node); } } }); // 标记已替换完成 window._navLinksReplaced = true; } // 替换代码区域中的域名 function replaceCodeDomains() { // 特别处理span.hljs-string和span.njs-string元素 document.querySelectorAll('span.hljs-string, span.njs-string, span[class*="hljs-string"], span[class*="njs-string"]').forEach(span => { if (span.textContent && span.textContent.includes('huggingface.co')) { span.textContent = span.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } }); // 替换hljs-string类的span中的域名(移除多余的转义符号) document.querySelectorAll('span.hljs-string, span[class*="hljs-string"]').forEach(span => { if (span.textContent && span.textContent.includes('huggingface.co')) { span.textContent = span.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } }); // 替换pre和code标签中包含git clone命令的域名 document.querySelectorAll('pre, code').forEach(element => { if (element.textContent && element.textContent.includes('git clone')) { const text = element.innerHTML; if (text.includes('huggingface.co')) { element.innerHTML = text.replace(/huggingface.co/g, 'aifasthub.com'); } } }); // 处理特定的命令行示例 document.querySelectorAll('pre, code').forEach(element => { const text = element.innerHTML; if (text.includes('huggingface.co')) { // 针对git clone命令的专门处理 if (text.includes('git clone') || text.includes('GIT_LFS_SKIP_SMUDGE=1')) { element.innerHTML = text.replace(/huggingface.co/g, 'aifasthub.com'); } } }); // 特别处理模型下载页面上的代码片段 document.querySelectorAll('.flex.border-t, .svelte_hydrator, .inline-block').forEach(container => { const content = container.innerHTML; if (content && content.includes('huggingface.co')) { container.innerHTML = content.replace(/huggingface.co/g, 'aifasthub.com'); } }); // 特别处理模型仓库克隆对话框中的代码片段 try { // 查找包含"Clone this model repository"标题的对话框 const cloneDialog = document.querySelector('.svelte_hydration_boundary, [data-target="MainHeader"]'); if (cloneDialog) { // 查找对话框中所有的代码片段和命令示例 const codeElements = cloneDialog.querySelectorAll('pre, code, span'); codeElements.forEach(element => { if (element.textContent && element.textContent.includes('huggingface.co')) { if (element.innerHTML.includes('huggingface.co')) { element.innerHTML = element.innerHTML.replace(/huggingface.co/g, 'aifasthub.com'); } else { element.textContent = element.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } } }); } // 更精确地定位克隆命令中的域名 document.querySelectorAll('[data-target]').forEach(container => { const codeBlocks = container.querySelectorAll('pre, code, span.hljs-string'); codeBlocks.forEach(block => { if (block.textContent && block.textContent.includes('huggingface.co')) { if (block.innerHTML.includes('huggingface.co')) { block.innerHTML = block.innerHTML.replace(/huggingface.co/g, 'aifasthub.com'); } else { block.textContent = block.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } } }); }); } catch (e) { // 错误处理但不打印日志 } } // 当DOM加载完成后执行替换 if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', () => { replaceHeaderBranding(); replaceNavigationLinks(); replaceCodeDomains(); // 只在必要时执行替换 - 3秒后再次检查 setTimeout(() => { if (!window._navLinksReplaced) { console.log('[Client] 3秒后重新检查导航链接'); replaceNavigationLinks(); } }, 3000); }); } else { replaceHeaderBranding(); replaceNavigationLinks(); replaceCodeDomains(); // 只在必要时执行替换 - 3秒后再次检查 setTimeout(() => { if (!window._navLinksReplaced) { console.log('[Client] 3秒后重新检查导航链接'); replaceNavigationLinks(); } }, 3000); } // 增加一个MutationObserver来处理可能的动态元素加载 const observer = new MutationObserver(mutations => { // 检查是否导航区域有变化 const hasNavChanges = mutations.some(mutation => { // 检查是否存在header或nav元素变化 return Array.from(mutation.addedNodes).some(node => { if (node.nodeType === Node.ELEMENT_NODE) { // 检查是否是导航元素或其子元素 if (node.tagName === 'HEADER' || node.tagName === 'NAV' || node.querySelector('header, nav')) { return true; } // 检查是否在导航元素内部 let parent = node.parentElement; while (parent) { if (parent.tagName === 'HEADER' || parent.tagName === 'NAV') { return true; } parent = parent.parentElement; } } return false; }); }); // 只在导航区域有变化时执行替换 if (hasNavChanges) { // 重置替换状态,允许再次替换 window._navLinksReplaced = false; replaceHeaderBranding(); replaceNavigationLinks(); } }); // 开始观察document.body的变化,包括子节点 if (document.body) { observer.observe(document.body, { childList: true, subtree: true }); } else { document.addEventListener('DOMContentLoaded', () => { observer.observe(document.body, { childList: true, subtree: true }); }); } })(); \n\n```\n\n## Specifications\n\n{{Specifications}}\n\n## Browser compatibility\n\n{{Compat}}\n\n## See also\n\n- [Drag and drop](/en-US/docs/Web/API/HTML_Drag_and_Drop_API)\n- [Drag Operations](/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Drag_operations)\n- [Recommended Drag Types](/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Recommended_drag_types)\n- [DataTransfer test - Paste or Drag](https://codepen.io/tech_query/pen/MqGgap)\n"},"__index_level_0__":{"kind":"number","value":0,"string":"0"}}},{"rowIdx":316,"cells":{"repo_id":{"kind":"string","value":"data/mdn-content/files/en-us/web/api/datatransfer"},"file_path":{"kind":"string","value":"data/mdn-content/files/en-us/web/api/datatransfer/addelement/index.md"},"content":{"kind":"string","value":"---\ntitle: \"DataTransfer: addElement() method\"\nshort-title: addElement()\nslug: Web/API/DataTransfer/addElement\npage-type: web-api-instance-method\nstatus:\n - experimental\n - non-standard\nbrowser-compat: api.DataTransfer.addElement\n---\n\n{{APIRef(\"HTML Drag and Drop API\")}}{{SeeCompatTable}}{{Non-standard_header}}\n\nThe **`DataTransfer.addElement()`** method sets the drag source\nto the given element. This element will be the element to which {{domxref(\"HTMLElement/drag_event\", \"drag\")}} and\n{{domxref(\"HTMLElement/dragend_event\", \"dragend\")}} events are fired, and not the default target (the node that was\ndragged).\n\n> **Note:** This method is Firefox-specific.\n\n## Syntax\n\n```js-nolint\naddElement(element)\n```\n\n### Parameters\n\n- `element`\n - : The {{domxref(\"Element\")}} to set as the drag source.\n\n### Return value\n\nNone ({{jsxref(\"undefined\")}}).\n\n## Examples\n\nThis example shows the use of the `addElement()` method\n\n```js\nfunction change_drag_node(event, node) {\n const dt = event.dataTransfer;\n dt.addElement(node);\n}\n```\n\n## Specifications\n\nThis method is not defined in any Web standard.\n\n## Browser compatibility\n\n{{Compat}}\n\n## See also\n\n- [Drag and drop](/en-US/docs/Web/API/HTML_Drag_and_Drop_API)\n- [Drag Operations](/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Drag_operations)\n- [Recommended Drag Types](/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Recommended_drag_types)\n- [DataTransfer test - Paste or Drag](https://codepen.io/tech_query/pen/MqGgap)\n"},"__index_level_0__":{"kind":"number","value":0,"string":"0"}}},{"rowIdx":317,"cells":{"repo_id":{"kind":"string","value":"data/mdn-content/files/en-us/web/api/datatransfer"},"file_path":{"kind":"string","value":"data/mdn-content/files/en-us/web/api/datatransfer/items/index.md"},"content":{"kind":"string","value":"---\ntitle: \"DataTransfer: items property\"\nshort-title: items\nslug: Web/API/DataTransfer/items\npage-type: web-api-instance-property\nbrowser-compat: api.DataTransfer.items\n---\n\n{{APIRef(\"HTML Drag and Drop API\")}}\n\nThe read-only {{domxref(\"DataTransfer\")}} property `items` property is a\n{{domxref(\"DataTransferItemList\",\"list\")}} of the {{domxref(\"DataTransferItem\",\"data\n transfer items\", \"\", \"nocode\")}} in a drag operation. The list includes one item for each item in the\noperation and if the operation had no items, the list is empty.\n\n## Value\n\nA {{domxref(\"DataTransferItemList\")}} object containing {{domxref(\"DataTransferItem\")}}\nobjects representing the items being dragged in a drag operation, one list item for each\nobject being dragged. If the drag operation had no data, the list is empty.\n\n## Examples\n\n### Logging dragged items\n\nThis example uses `items` to log information about dragged items.\n\n#### HTML\n\n```html\n
    \n
  • Drag Item 1 to the Drop Zone
  • \n
  • Drag Item 2 to the Drop Zone
  • \n
\n
Drop Zone
\n\n\n```\n\n#### CSS\n\n```css\ndiv {\n margin: 0em;\n padding: 2em;\n}\n\n#target {\n border: 1px solid black;\n}\n```\n\n#### JavaScript\n\n```js\nfunction dragstartHandler(ev) {\n console.log(`dragstart: target.id = ${ev.target.id}`);\n // Add this element's id to the drag payload so the drop handler will\n // know which element to add to its tree\n ev.dataTransfer.setData(\"text/plain\", ev.target.id);\n ev.dataTransfer.effectAllowed = \"move\";\n}\n\nfunction dropHandler(ev) {\n ev.preventDefault();\n // Get the id of the target and add the moved element to the target's DOM\n const data = ev.dataTransfer.getData(\"text\");\n ev.target.appendChild(document.getElementById(data));\n // Print each item's \"kind\" and \"type\"\n if (ev.dataTransfer.items) {\n for (const item of ev.dataTransfer.items) {\n console.log(`kind = ${item.kind}, type = ${item.type}`);\n }\n }\n}\n\nfunction dragoverHandler(ev) {\n ev.preventDefault();\n // Set the dropEffect to move\n ev.dataTransfer.dropEffect = \"move\";\n}\n\nconst source1 = document.querySelector(\"#source1\");\nconst source2 = document.querySelector(\"#source2\");\nconst target = document.querySelector(\"#target\");\n\nsource1.addEventListener(\"dragstart\", dragstartHandler);\nsource2.addEventListener(\"dragstart\", dragstartHandler);\ntarget.addEventListener(\"dragover\", dragoverHandler);\ntarget.addEventListener(\"drop\", dropHandler);\n\nconst reset = document.querySelector(\"#reset\");\nreset.addEventListener(\"click\", () => document.location.reload());\n```\n\n#### Result\n\n{{EmbedLiveSample(\"Logging dragged items\", 0, 400)}}\n\n## Specifications\n\n{{Specifications}}\n\n## Browser compatibility\n\n{{Compat}}\n\n## See also\n\n- [Drag and drop](/en-US/docs/Web/API/HTML_Drag_and_Drop_API)\n- [Drag Operations](/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Drag_operations)\n- [Recommended Drag Types](/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Recommended_drag_types)\n- [DataTransfer test - Paste or Drag](https://codepen.io/tech_query/pen/MqGgap)\n"},"__index_level_0__":{"kind":"number","value":0,"string":"0"}}},{"rowIdx":318,"cells":{"repo_id":{"kind":"string","value":"data/mdn-content/files/en-us/web/api/datatransfer"},"file_path":{"kind":"string","value":"data/mdn-content/files/en-us/web/api/datatransfer/types/index.md"},"content":{"kind":"string","value":"---\ntitle: \"DataTransfer: types property\"\nshort-title: types\nslug: Web/API/DataTransfer/types\npage-type: web-api-instance-property\nbrowser-compat: api.DataTransfer.types\n---\n\n{{APIRef(\"HTML Drag and Drop API\")}}\n\nThe **`DataTransfer.types`** read-only property returns the available types\nthat exist in the {{domxref(\"DataTransfer.items\",\"items\")}}.\n\n## Value\n\nAn array of the data formats used in the drag operation. Each format is a string\nwhich is generally a MIME type such as `text/plain` or `text/html`. If the drag\noperation included no data, this list will be empty. If any files are included in\nthe drag operation, then one of the types will be the string `Files`.\n\n## Examples\n\nThis example shows the use of the `types` and\n{{domxref(\"DataTransfer.items\",\"items\")}} properties.\n\n```html\n\n\n Examples of DataTransfer.{types,items} properties\n \n \n \n \n

\n Examples of DataTransfer.{types,\n items} properties\n

\n
    \n
  • \n Drag Item 1 to the Drop Zone\n
  • \n
  • \n Drag Item 2 to the Drop Zone\n
  • \n
\n \n Drop Zone\n
\n \n\n```\n\n## Specifications\n\n{{Specifications}}\n\n## Browser compatibility\n\n{{Compat}}\n\n## See also\n\n- [Drag and drop](/en-US/docs/Web/API/HTML_Drag_and_Drop_API)\n- [Drag Operations](/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Drag_operations)\n- [Recommended Drag Types](/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Recommended_drag_types)\n- [DataTransfer test - Paste or Drag](https://codepen.io/tech_query/pen/MqGgap)\n"},"__index_level_0__":{"kind":"number","value":0,"string":"0"}}},{"rowIdx":319,"cells":{"repo_id":{"kind":"string","value":"data/mdn-content/files/en-us/web/api/datatransfer"},"file_path":{"kind":"string","value":"data/mdn-content/files/en-us/web/api/datatransfer/getdata/index.md"},"content":{"kind":"string","value":"---\ntitle: \"DataTransfer: getData() method\"\nshort-title: getData()\nslug: Web/API/DataTransfer/getData\npage-type: web-api-instance-method\nbrowser-compat: api.DataTransfer.getData\n---\n\n{{APIRef(\"HTML DOM\")}}\n\nThe **`DataTransfer.getData()`**\nmethod retrieves drag data (as a string) for the specified type.\nIf the drag operation does not include data, this method returns an empty\nstring.\n\nExample data types are `text/plain` and `text/uri-list`.\n\n## Syntax\n\n```js-nolint\ngetData(format)\n```\n\n### Parameters\n\n- `format`\n - : A string representing the type of data to retrieve.\n\n### Return value\n\nA string representing the drag data for the specified `format`. If the drag operation has no data or the operation has no data for the specified `format`, this method returns an empty string.\n\n### Caveats\n\n- Data availability\n\n - : The [HTML Drag and Drop Specification](https://www.w3.org/TR/2011/WD-html5-20110113/dnd.html#drag-data-store-mode) dictates a `drag data store mode`.\n This may result in unexpected behavior, being\n **`DataTransfer.getData()`** not returning an expected\n value, because not all browsers enforce this restriction.\n\n During the `dragstart` and `drop` events, it is safe to access the data. For all other events, the data should be considered unavailable. Despite this, the items and their formats can still be enumerated.\n\n## Examples\n\nThis example shows the use of the {{domxref(\"DataTransfer\")}} object's\n{{domxref(\"DataTransfer.getData()\",\"getData()\")}} and\n{{domxref(\"DataTransfer.setData()\",\"setData()\")}} methods.\n\n### HTML\n\n```html\n
\n drag me to the other box\n
\n
\n```\n\n### CSS\n\n```css\n#div1,\n#div2 {\n width: 100px;\n height: 50px;\n padding: 10px;\n border: 1px solid #aaaaaa;\n}\n```\n\n### JavaScript\n\n```js\nfunction allowDrop(allowdropevent) {\n allowdropevent.target.style.color = \"blue\";\n allowdropevent.preventDefault();\n}\n\nfunction drag(dragevent) {\n dragevent.dataTransfer.setData(\"text\", dragevent.target.id);\n dragevent.target.style.color = \"green\";\n}\n\nfunction drop(dropevent) {\n dropevent.preventDefault();\n const data = dropevent.dataTransfer.getData(\"text\");\n dropevent.target.appendChild(document.getElementById(data));\n document.getElementById(\"drag\").style.color = \"black\";\n}\n```\n\n### Result\n\n{{EmbedLiveSample('Examples', 600) }}\n\n## Specifications\n\n{{Specifications}}\n\n## Browser compatibility\n\n{{Compat}}\n\n## See also\n\n- [Drag and drop](/en-US/docs/Web/API/HTML_Drag_and_Drop_API)\n- [Drag Operations](/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Drag_operations)\n- [Recommended Drag Types](/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Recommended_drag_types)\n- [DataTransfer test - Paste or Drag](https://codepen.io/tech_query/pen/MqGgap)\n"},"__index_level_0__":{"kind":"number","value":0,"string":"0"}}},{"rowIdx":320,"cells":{"repo_id":{"kind":"string","value":"data/mdn-content/files/en-us/web/api/datatransfer"},"file_path":{"kind":"string","value":"data/mdn-content/files/en-us/web/api/datatransfer/effectallowed/index.md"},"content":{"kind":"string","value":"---\ntitle: \"DataTransfer: effectAllowed property\"\nshort-title: effectAllowed\nslug: Web/API/DataTransfer/effectAllowed\npage-type: web-api-instance-property\nbrowser-compat: api.DataTransfer.effectAllowed\n---\n\n{{APIRef(\"HTML Drag and Drop API\")}}\n\nThe **`DataTransfer.effectAllowed`** property specifies the\neffect that is allowed for a drag operation. The _copy_ operation is used to\nindicate that the data being dragged will be copied from its present location to the\ndrop location. The _move_ operation is used to indicate that the data being\ndragged will be moved, and the _link_ operation is used to indicate that some\nform of relationship or connection will be created between the source and drop\nlocations.\n\nThis property should be set in the {{domxref(\"HTMLElement/dragstart_event\", \"dragstart\")}} event to set the desired drag\neffect for the drag source. Within the {{domxref(\"HTMLElement/dragenter_event\", \"dragenter\")}} and {{domxref(\"HTMLElement/dragover_event\", \"dragover\")}}\nevent handlers, this property will be set to whatever value was assigned during the\n{{domxref(\"HTMLElement/dragstart_event\", \"dragstart\")}} event, thus `effectAllowed` may be used to determine\nwhich effect is permitted.\n\nAssigning a value to `effectAllowed` in events other than\n{{domxref(\"HTMLElement/dragstart_event\", \"dragstart\")}} has no effect.\n\n## Value\n\nA string representing the drag operation that is allowed. The\npossible values are:\n\n- `none`\n - : The item may not be dropped.\n- `copy`\n - : A copy of the source item may be made at the new location.\n- `copyLink`\n - : A copy or link operation is permitted.\n- `copyMove`\n - : A copy or move operation is permitted.\n- `link`\n - : A link may be established to the source at the new location.\n- `linkMove`\n - : A link or move operation is permitted.\n- `move`\n - : An item may be moved to a new location.\n- `all`\n - : All operations are permitted.\n- `uninitialized`\n - : The default value when the effect has not been set, equivalent to all.\n\nAssigning any other value to `effectAllowed` has no effect and the old value\nis retained.\n\n## Examples\n\n### Setting effectAllowed\n\nIn this example we set `effectAllowed` to `\"move\"` in the `dragstart` handler.\n\n#### HTML\n\n```html\n
\n

\n Select this element, drag it to the Drop Zone and then release the selection\n to move the element.\n

\n
\n
Drop Zone
\n
\n\n```\n\n#### CSS\n\n```css\ndiv {\n  margin: 0em;\n  padding: 2em;\n}\n\n#source {\n  color: blue;\n  border: 1px solid black;\n}\n\n#target {\n  border: 1px solid black;\n}\n\n#output {\n  height: 100px;\n  overflow: scroll;\n}\n```\n\n#### JavaScript\n\n```js\nfunction dragstartHandler(ev) {\n  log(`dragstart: effectAllowed = ${ev.dataTransfer.effectAllowed}`);\n\n  // Add this element's id to the drag payload so the drop handler will\n  // know which element to add to its tree\n  ev.dataTransfer.setData(\"text\", ev.target.id);\n  ev.dataTransfer.effectAllowed = \"move\";\n}\n\nfunction dropHandler(ev) {\n  log(`drop: effectAllowed = ${ev.dataTransfer.effectAllowed}`);\n\n  ev.preventDefault();\n  // Get the id of the target and add the element to the target's DOM\n  const data = ev.dataTransfer.getData(\"text\");\n  ev.target.appendChild(document.getElementById(data));\n}\n\nfunction dragoverHandler(ev) {\n  log(`dragover: effectAllowed = ${ev.dataTransfer.effectAllowed}`);\n  ev.preventDefault();\n}\n\nconst source = document.querySelector(\"#source\");\nconst target = document.querySelector(\"#target\");\n\nsource.addEventListener(\"dragstart\", dragstartHandler);\ntarget.addEventListener(\"dragover\", dragoverHandler);\ntarget.addEventListener(\"drop\", dropHandler);\n\nfunction log(message) {\n  const output = document.querySelector(\"#output\");\n  output.textContent = `${output.textContent}\\n${message}`;\n  output.scrollTop = output.scrollHeight;\n}\n\nconst reset = document.querySelector(\"#reset\");\nreset.addEventListener(\"click\", () => document.location.reload());\n```\n\n#### Result\n\n{{EmbedLiveSample(\"Setting effectAllowed\", 0, 400)}}\n\n## Specifications\n\n{{Specifications}}\n\n## Browser compatibility\n\n{{Compat}}\n\n## See also\n\n- [Drag and drop](/en-US/docs/Web/API/HTML_Drag_and_Drop_API)\n- [Drag Operations](/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Drag_operations)\n- [Recommended Drag Types](/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Recommended_drag_types)\n- [DataTransfer test - Paste or Drag](https://codepen.io/tech_query/pen/MqGgap)\n"},"__index_level_0__":{"kind":"number","value":0,"string":"0"}}},{"rowIdx":321,"cells":{"repo_id":{"kind":"string","value":"data/mdn-content/files/en-us/web/api/datatransfer"},"file_path":{"kind":"string","value":"data/mdn-content/files/en-us/web/api/datatransfer/setdata/index.md"},"content":{"kind":"string","value":"---\ntitle: \"DataTransfer: setData() method\"\nshort-title: setData()\nslug: Web/API/DataTransfer/setData\npage-type: web-api-instance-method\nbrowser-compat: api.DataTransfer.setData\n---\n\n{{APIRef(\"HTML Drag and Drop API\")}}\n\nThe **`DataTransfer.setData()`** method sets the drag\noperation's {{domxref(\"DataTransfer\",\"drag data\")}} to the specified data and type. If\ndata for the given type does not exist, it is added at the end of the drag data store,\nsuch that the last item in the {{domxref(\"DataTransfer.types\",\"types\")}} list will be\nthe new type. If data for the given type already exists, the existing data is replaced\nin the same position. That is, the order of the\n{{domxref(\"DataTransfer.types\",\"types\")}} list is not changed when replacing data of the\nsame type.\n\nExample data types are `text/plain` and `text/uri-list`.\n\n## Syntax\n\n```js-nolint\nsetData(format, data)\n```\n\n### Parameters\n\n- `format`\n  - : A string representing the type of the drag data to add to the\n    {{domxref(\"DataTransfer\",\"drag object\")}}.\n- `data`\n  - : A string representing the data to add to the\n    {{domxref(\"DataTransfer\",\"drag object\")}}.\n\n### Return value\n\nNone ({{jsxref(\"undefined\")}}).\n\n## Examples\n\n### Dragging an element\n\nIn this example we can drag a {{HTMLElement(\"p\")}} element into a target {{HTMLElement(\"div\")}} element.\n\n- In the `dragstart` handler, we use {{domxref(\"DataTransfer.setData\",\"setData()\")}} to add the `id` of the `

` element to the {{domxref(\"DataTransfer\")}} object.\n\n- In the `drop` handler we retrieve the `id` and use it to move the `

` element into the target.\n\n#### HTML\n\n```html\n

\n

\n Select this element, drag it to the drop zone and then release the selection\n to move the element.\n

\n
\n
Drop Zone
\n\n\n```\n\n#### CSS\n\n```css\ndiv {\n margin: 0.5em 0;\n padding: 2em;\n}\n\n#target,\n#source {\n border: 1px solid black;\n padding: 0.5rem;\n}\n\n.dragging {\n background-color: pink;\n}\n```\n\n#### JavaScript\n\n```js\nconst source = document.querySelector(\"#source\");\nsource.addEventListener(\"dragstart\", (ev) => {\n console.log(\"dragStart\");\n // Change the source element's background color\n // to show that drag has started\n ev.currentTarget.classList.add(\"dragging\");\n // Clear the drag data cache (for all formats/types)\n ev.dataTransfer.clearData();\n // Set the drag's format and data.\n // Use the event target's id for the data\n ev.dataTransfer.setData(\"text/plain\", ev.target.id);\n});\nsource.addEventListener(\"dragend\", (ev) =>\n ev.target.classList.remove(\"dragging\"),\n);\n\nconst target = document.querySelector(\"#target\");\ntarget.addEventListener(\"dragover\", (ev) => {\n console.log(\"dragOver\");\n ev.preventDefault();\n});\ntarget.addEventListener(\"drop\", (ev) => {\n console.log(\"Drop\");\n ev.preventDefault();\n // Get the data, which is the id of the source element\n const data = ev.dataTransfer.getData(\"text\");\n const source = document.getElementById(data);\n ev.target.appendChild(source);\n});\n\nconst reset = document.querySelector(\"#reset\");\nreset.addEventListener(\"click\", () => document.location.reload());\n```\n\n#### Result\n\n{{EmbedLiveSample(\"Dragging an element\", \"\", 250)}}\n\n## Specifications\n\n{{Specifications}}\n\n## Browser compatibility\n\n{{Compat}}\n\n## See also\n\n- [Drag and drop](/en-US/docs/Web/API/HTML_Drag_and_Drop_API)\n- [Drag Operations](/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Drag_operations)\n- [Recommended Drag Types](/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Recommended_drag_types)\n- [DataTransfer test - Paste or Drag](https://codepen.io/tech_query/pen/MqGgap)\n"},"__index_level_0__":{"kind":"number","value":0,"string":"0"}}},{"rowIdx":322,"cells":{"repo_id":{"kind":"string","value":"data/mdn-content/files/en-us/web/api/datatransfer"},"file_path":{"kind":"string","value":"data/mdn-content/files/en-us/web/api/datatransfer/dropeffect/index.md"},"content":{"kind":"string","value":"---\ntitle: \"DataTransfer: dropEffect property\"\nshort-title: dropEffect\nslug: Web/API/DataTransfer/dropEffect\npage-type: web-api-instance-property\nbrowser-compat: api.DataTransfer.dropEffect\n---\n\n{{APIRef(\"HTML Drag and Drop API\")}}\n\nThe **`DataTransfer.dropEffect`** property controls the\nfeedback (typically visual) the user is given during a drag and drop operation. It will\naffect which cursor is displayed while dragging. For example, when the user hovers over\na target drop element, the browser's cursor may indicate which type of operation will\noccur.\n\nWhen the {{domxref(\"DataTransfer\")}} object is created, `dropEffect` is set\nto a string value. On getting, it returns its current value. On setting, if the new\nvalue is one of the values listed below, then the property's current value will be set\nto the new value and other values will be ignored.\n\nFor the {{domxref(\"HTMLElement/dragenter_event\", \"dragenter\")}} and {{domxref(\"HTMLElement/dragover_event\", \"dragover\")}} events,\n`dropEffect` will be initialized based on what action the user is requesting.\nHow this is determined is platform specific, but typically the user can press modifier\nkeys such as the alt key to adjust the desired action. Within event handlers for\n{{domxref(\"HTMLElement/dragenter_event\", \"dragenter\")}} and {{domxref(\"HTMLElement/dragover_event\", \"dragover\")}} events, `dropEffect` should\nbe modified if a different action is desired than the action that the user is\nrequesting.\n\nFor the {{domxref(\"HTMLElement/drop_event\", \"drop\")}} and {{domxref(\"HTMLElement/dragend_event\", \"dragend\")}} events, `dropEffect` will\nbe set to the action that was desired, which will be the value `dropEffect`\nhad after the last {{domxref(\"HTMLElement/dragenter_event\", \"dragenter\")}} or {{domxref(\"HTMLElement/dragover_event\", \"dragover\")}} event. In a\n{{domxref(\"HTMLElement/dragend_event\", \"dragend\")}} event, for instance, if the desired dropEffect is \"move\", then the\ndata being dragged should be removed from the source.\n\n## Value\n\nA string representing the drag operation effect. The possible values\nare:\n\n- `copy`\n - : A copy of the source item is made at the new location.\n- `move`\n - : An item is moved to a new location.\n- `link`\n - : A link is established to the source at the new location.\n- `none`\n - : The item may not be dropped.\n\nAssigning any other value to `dropEffect` has no effect and the old value is\nretained.\n\n## Example\n\nThis example shows the use of the `dropEffect` and\n{{domxref(\"DataTransfer.effectAllowed\",\"effectAllowed\")}} properties.\n\n### HTML\n\n```html\n
\n

\n Select this element, drag it to the Drop Zone and then release the selection\n to move the element.\n

\n
\n\n Drop Zone\n
\n```\n\n### CSS\n\n```css\ndiv {\n margin: 0em;\n padding: 2em;\n}\n\n#source {\n color: blue;\n border: 1px solid black;\n}\n\n#target {\n border: 1px solid black;\n}\n```\n\n### JavaScript\n\n```js\nfunction dragstart_handler(ev) {\n console.log(\n `dragStart: dropEffect = ${ev.dataTransfer.dropEffect} ; effectAllowed = ${ev.dataTransfer.effectAllowed}`,\n );\n\n // Add this element's id to the drag payload so the drop handler will\n // know which element to add to its tree\n ev.dataTransfer.setData(\"text\", ev.target.id);\n ev.dataTransfer.effectAllowed = \"move\";\n}\n\nfunction drop_handler(ev) {\n console.log(\n `drop: dropEffect = ${ev.dataTransfer.dropEffect} ; effectAllowed = ${ev.dataTransfer.effectAllowed}`,\n );\n ev.preventDefault();\n\n // Get the id of the target and add the moved element to the target's DOM\n const data = ev.dataTransfer.getData(\"text\");\n ev.target.appendChild(document.getElementById(data));\n}\n\nfunction dragover_handler(ev) {\n console.log(\n `dragOver: dropEffect = ${ev.dataTransfer.dropEffect} ; effectAllowed = ${ev.dataTransfer.effectAllowed}`,\n );\n ev.preventDefault();\n // Set the dropEffect to move\n ev.dataTransfer.dropEffect = \"move\";\n}\n```\n\n{{EmbedLiveSample('Example', 300, 250)}}\n\n## Specifications\n\n{{Specifications}}\n\n## Browser compatibility\n\n{{Compat}}\n\n## See also\n\n- [Drag and drop](/en-US/docs/Web/API/HTML_Drag_and_Drop_API)\n- [Drag Operations](/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Drag_operations)\n- [Recommended Drag Types](/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Recommended_drag_types)\n- [DataTransfer test - Paste or Drag](https://codepen.io/tech_query/pen/MqGgap)\n"},"__index_level_0__":{"kind":"number","value":0,"string":"0"}}},{"rowIdx":323,"cells":{"repo_id":{"kind":"string","value":"data/mdn-content/files/en-us/web/api"},"file_path":{"kind":"string","value":"data/mdn-content/files/en-us/web/api/credential_management_api/index.md"},"content":{"kind":"string","value":"---\ntitle: Credential Management API\nslug: Web/API/Credential_Management_API\npage-type: web-api-overview\nbrowser-compat:\n - api.Credential\n - api.CredentialsContainer\n - api.FederatedCredential\n - api.PasswordCredential\nspec-urls: https://w3c.github.io/webappsec-credential-management/\n---\n\n{{DefaultAPISidebar(\"Credential Management API\")}}{{securecontext_header}}\n\nThe Credential Management API lets a website store and retrieve password, public key, and federated credentials. These capabilities allow users to sign in without typing passwords, see the federated account they used to sign in to a site, and resume a session without the explicit sign-in flow of an expired session.\n\n## Concepts and usage\n\nThis API lets websites interact with a user agent's password system directly so that websites can deal in a uniform way with site credentials and user agents can provide better assistance with the management of their credentials. For example, user agents have a particularly hard time dealing with federated identity providers or esoteric sign-in mechanisms.\n\nTo address these problems, the Credential Management API provides ways for a website to store and retrieve different types of credentials. This gives users capabilities such as seeing the federated account they used to sign on to a site, or resuming a session without the explicit sign-in flow of an expired session.\n\n> **Note:** This API is restricted to top-level contexts. Calls to `get()` and `store()` within an `