MediaWiki:Gadget-wikidiff2.js
外观
注意:在发布之后,您可能需要清除浏览器缓存才能看到所作出的更改的影响。
- Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5或Ctrl-R(Mac为⌘-R)
- Google Chrome:按Ctrl-Shift-R(Mac为⌘-Shift-R)
- Edge:按住Ctrl的同时单击刷新,或按Ctrl-F5。
/**
* -------------------------------------------------------------------------
* !!! DON'T MODIFY THIS PAGE MANUALLY, YOUR CHANGES WILL BE OVERWRITTEN !!!
* -------------------------------------------------------------------------
*/
var _addText = '{{GHIACode|page=GHIA:MoegirlPediaInterfaceCodes/blob/master/src/gadgets/wikidiff2/Gadget-wikidiff2.js|user=[[U:SaoMikoto]]|co-authors=GH:sourcery-ai[bot]|longId=6962b410b343add1fa6208b950a66fa6568a4406|shortId=6962b410|summary=feat: 添加 wikidiff2 (#857)|body=<nowiki>Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]📧users.noreply.github.com></nowiki>}}';
/* <pre> */
"use strict";(async()=>{const n=document.querySelector("table.diff");if(n)try{await mw.loader.getScript("https://fastly.jsdelivr.net/npm/diff@7.0.0/dist/diff.min.js"),(i=>{for(const t of n.rows){const n=t.cells;let e,f;if(4===n.length)e=n[1],f=n[3];else{if(3!==n.length)continue;2===n[2].colSpan?e=n[1]:2===n[0].colSpan&&(f=n[2])}const c=e?.textContent??"",o=f?.textContent??"";if(!c&&!o)continue;const s=i.diffChars(c,o),render=(n,i)=>{if(!n)return;const t=document.createElement("div");s.forEach(n=>{if(!(i&&n.added||!i&&n.removed))if(i?n.removed:n.added){const e=i?"del":"ins",f=document.createElement(e);f.className="diffchange diffchange-inline",f.appendChild(document.createTextNode(n.value)),t.appendChild(f)}else t.appendChild(document.createTextNode(n.value))}),n.innerHTML="",n.appendChild(t)};render(e,!0),render(f,!1)}})(window.Diff),console.log("wikidiff2 loaded.")}catch(n){console.error(`加载JsDiff时发生错误:${n}`)}})();
/* </pre> */