xxhk.org

学习骇客

点击标签,进行主题学习

2024 / 8 / 15

电脑上配合插件 才能点击,Ankimobile 直接点击,Ankidroid 目前还不行。

点击标签的插件:Clickable Tags v2.0

/* 针对可点击标签的样式禁用 */ kbd { all:unset !important; }

点击双链的插件:Anki Note Linker

笔记样式

默认通过[词语|ID]的形式引用,应该可以自定义。

A1CDF::心智模型::联系 {{c1::《思考,快与慢》::行为经济学著作}}[高效学习|nid1723471779980] [智力|nid1723520209486] [记忆法|nid1723520209510] 填空题含模板代码修改

模板样式

关键:字段设置 .className 供函数调用。

正面:

{{#Tags}}<div class="biaoqian tagsRender" >{{clickable:Tags}}</div>{{/Tags}} <br> <div class="zm linkRender" style="">{{edit:cloze:图式}}</div> <script> // 标签可点击,将标签字段放到 class="tagsRender" 的标签对之间 var disableLinks = false; if (!window.AnkiNoteLinkerIsActive) { const renderLinks = _ => { // 查找页面中所有带有 'tagsRender' 类的元素并对其进行遍历处理 document.querySelectorAll('.tagsRender').forEach(element => { const tags = element.innerText.trim().split(/\s+/); // 将 {{Tags}} 的内容按空格拆分成数组 let tagLinks = tags.map(tag => { let link; if (document.documentElement.classList.contains('iphone') || document.documentElement.classList.contains('ipad')) { link = `anki://x-callback-url/search?query=tag%3a${encodeURIComponent(tag)}`; } else try { window.jsAPI ||= new AnkiDroidJS({ version: "0.0.3", developer: "github.com/gugutu" }); link = `javascript:window.jsAPI.ankiSearchCard(\`tag:${tag}\`)`; } catch (e) { link = `https://ankiuser.net/search/?q=tag%3A${encodeURIComponent(tag)}' target='_blank`; } return disableLinks ? `${tag}` : `<a href='${link}' class='tagLink'>${tag}</a>`; }); // 将所有生成的标签链接组合成一个字符串,并替换 element 的内容 element.innerHTML = tagLinks.join(' '); }); }; document.readyState !== 'loading' ? renderLinks() : document.addEventListener('DOMContentLoaded', renderLinks, { once: true }); } </script> <script> // 笔记正文链接可点击跳转 var disableLinks = false; // 改为true将禁用链接的跳转功能 if (!window.AnkiNoteLinkerIsActive) { const renderLinks = _ => { document.querySelectorAll('.linkRender').forEach(element => { // You can rename "linkRender" on this line, but leave the "." in front element.innerHTML = element.innerHTML.replace( /\[((?:[^\[]|\\\[)*)\|nid(\d{13})\]/g, (match, title, nid) => { title = title.replace(/\\\[/g, '['); let link; if (document.documentElement.classList.contains('iphone') || document.documentElement.classList.contains('ipad')) { link = `anki://x-callback-url/search?query=nid%3a${nid}`; } else try { window.jsAPI ||= new AnkiDroidJS({ version: "0.0.3", developer: "github.com/gugutu" }); link = `javascript:window.jsAPI.ankiSearchCard(\`nid:${nid}\`)`; } catch (e) { link = `https://ankiuser.net/edit/${nid}' target='_blank`; } return disableLinks ? `${title}` : `<a href='${link}' class='noteLink'>${title}</a>`; } ); }); }; document.readyState !== 'loading' ? renderLinks() : document.addEventListener('DOMContentLoaded', renderLinks, { once: true }); } </script>

背面:

{{#Tags}}<div class="biaoqian tagsRender" >{{clickable:Tags}}</div>{{/Tags}} <br> <div class="bm linkRender" style="">{{edit:cloze:图式}}</div> <br> <br> <div class="bm" class="yy" style="color:#4d4d4d;">{{edit:引用}}</div> <script> // 标签可点击,将标签字段放到 class="tagsRender" 的标签对之间 var disableLinks = false; if (!window.AnkiNoteLinkerIsActive) { const renderLinks = _ => { // 查找页面中所有带有 'tagsRender' 类的元素并对其进行遍历处理 document.querySelectorAll('.tagsRender').forEach(element => { const tags = element.innerText.trim().split(/\s+/); // 将 {{Tags}} 的内容按空格拆分成数组 let tagLinks = tags.map(tag => { let link; if (document.documentElement.classList.contains('iphone') || document.documentElement.classList.contains('ipad')) { link = `anki://x-callback-url/search?query=tag%3a${encodeURIComponent(tag)}`; } else try { window.jsAPI ||= new AnkiDroidJS({ version: "0.0.3", developer: "github.com/gugutu" }); link = `javascript:window.jsAPI.ankiSearchCard(\`tag:${tag}\`)`; } catch (e) { link = `https://ankiuser.net/search/?q=tag%3A${encodeURIComponent(tag)}' target='_blank`; } return disableLinks ? `${tag}` : `<a href='${link}' class='tagLink'>${tag}</a>`; }); // 将所有生成的标签链接组合成一个字符串,并替换 element 的内容 element.innerHTML = tagLinks.join(' '); }); }; document.readyState !== 'loading' ? renderLinks() : document.addEventListener('DOMContentLoaded', renderLinks, { once: true }); } </script> <script> // 笔记正文链接可点击跳转 var disableLinks = false; // 改为true将禁用链接的跳转功能 if (!window.AnkiNoteLinkerIsActive) { const renderLinks = _ => { document.querySelectorAll('.linkRender').forEach(element => { // You can rename "linkRender" on this line, but leave the "." in front element.innerHTML = element.innerHTML.replace( /\[((?:[^\[]|\\\[)*)\|nid(\d{13})\]/g, (match, title, nid) => { title = title.replace(/\\\[/g, '['); let link; if (document.documentElement.classList.contains('iphone') || document.documentElement.classList.contains('ipad')) { link = `anki://x-callback-url/search?query=nid%3a${nid}`; } else try { window.jsAPI ||= new AnkiDroidJS({ version: "0.0.3", developer: "github.com/gugutu" }); link = `javascript:window.jsAPI.ankiSearchCard(\`nid:${nid}\`)`; } catch (e) { link = `https://ankiuser.net/edit/${nid}' target='_blank`; } return disableLinks ? `${title}` : `<a href='${link}' class='noteLink'>${title}</a>`; } ); }); }; document.readyState !== 'loading' ? renderLinks() : document.addEventListener('DOMContentLoaded', renderLinks, { once: true }); } </script>