Skip to content

Instantly share code, notes, and snippets.

View gijigae's full-sized avatar

Sangmin Ahn gijigae

View GitHub Profile
@gijigae
gijigae / n2r_without_lexile.js
Created October 10, 2022 04:23
Newsela to Roam without Lexile
javascript:void function(){const a=document.querySelector("%23article-title").textContent,b=document.querySelector("h2[data-qa-selector=article_label_text]").textContent,c=document.querySelector("div span[data-qa-selector=word_count]").textContent,e=document.querySelector("article img").getAttribute("src"),f=document.evaluate("//span[text()='Published:']",document,null,XPathResult.ANY_TYPE,null),g=f.iterateNext(),h=new Date(g.nextElementSibling.textContent),i=(a=>{const b=a.getFullYear(),c=a.toLocaleString("en-us",{month:"long"}),d=(a=>a+(0<a%3F["th","st","nd","rd"][3<a%26%2621>a||3<a%2510%3F0:a%2510]:""))(a.getDate());return`${c} ${d}, ${b}`})(h),j=document.querySelectorAll("div[data-qa-selector=article_text] p,div[data-qa-selector=article_text] h2");let k=location.href;try{k=document.querySelector("link[rel='canonical']").getAttribute("href")}catch(a){console.log("canonical url is not found.")}const l=[`- Topic: %23[[${b}]]`,`Words: ${c}`,`Source: ${k}`,`![](${e})\n- `];let m=l.join("\n- "),o=!1;const p=a=>
@gijigae
gijigae / newsela2logesq.js
Created August 20, 2022 03:10
Bookmarklet source to copy Newsela article to Logseq
const roamfy = (d) => {
const ord = (n) => n + (n > 0 ? ['th', 'st', 'nd', 'rd'][(n > 3 && n < 21) || n % 10 > 3 ? 0 : n % 10] : '');
const year = d.getFullYear();
const month = d.toLocaleString('en-us', { month: 'long' });
const date = ord(d.getDate());
return `${month} ${date}, ${year}`
}
const title = document.querySelector("#article-title").textContent;
@gijigae
gijigae / youglish.md
Created July 28, 2022 01:05
YouGlish Template for Logseq
  • Template
    template:: tmpl-youglish template-including-parent:: false
@gijigae
gijigae / journey.txt
Created July 12, 2022 03:49
Mermaid sample for Journey diagram
```mermaid
journey
    title My working day
    section Go to work
      Make tea: 5: Me
      Go upstairs: 3: Me
      Do work: 1: Me, Cat
    section Go home
      Go downstairs: 5: Me
      Sit down: 5: Me
@gijigae
gijigae / banners-giu.json
Created July 9, 2022 01:53
Logseq Banners Plugin Setting for Grammar in Use
"giu": {
"pageIcon": "👩🏼‍🏫",
"banner": "https://images.unsplash.com/photo-1565022536102-f7645c84354a?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1746&q=80"
},
@gijigae
gijigae / ds4e.json
Created July 7, 2022 11:58
Logseq banner for DS4e program
"ds4e": {
"pageIcon": "👩🏻‍💻",
"banner": "https://i2.wp.com/www.dailycal.org/assets/uploads/2022/05/data_anissa-nishioka_file.jpg"
},
@gijigae
gijigae / cs50w.json
Created July 7, 2022 04:19
Image and icon for CS50W Banner
"cs50w": {
"pageIcon": "👩🏻‍💻",
"banner": "https://www.dropbox.com/s/w6qxfyyq9gmyzb3/harvard-cs50w-banner-web-programming.png?raw=1"
},
@gijigae
gijigae / YTTranscript2LS.js
Last active July 3, 2022 06:59
Bookmarklet script to extract YT transcript for Logseq
javascript:void%20function(){(function(){const%20a=()=%3Edocument.querySelectorAll(%22ytd-transcript-renderer%20ytd-transcript-segment-renderer%20%3E%20div%22),b=a=%3E{const%20b=Array.from(a),c=b.map(a=%3E{const%20b=Array.from(a.querySelectorAll(%22div%22)).slice(0,2),c=Array.from(a.querySelectorAll(%22yt-formatted-string%22)).slice(0,1);let%20d=b[0].textContent.trim();4===d.length%3Fd=`00:0${d}`:5===d.length%3Fd=`00:${d}`:7===d.length%26%26(d=`0${d}`);const%20e=%22{{youtube-timestamp%20%22+d+%22}}%22,f=c[0].textContent.trim().replace(/(\r\n|\n|\r)/gm,%22%20%22);return{timestamp:e,transcript:f}});let%20d=%22%22;c.forEach(a=%3E{d+=[`-%20${a.timestamp}`,`${a.transcript}\n`].join(%22%20%22)}),navigator.clipboard.writeText(d)};let%20c=a();if(0!==c.length)return%20void%20b(c);const%20d=setInterval(()=%3E{try{document.querySelector(%22ytd-menu-service-item-renderer.style-scope:nth-child(2)%20%3E%20tp-yt-paper-item:nth-child(1)%20%3E%20yt-formatted-string:nth-child(2)%22).click()}catch(a){return%20void%20console.log
@gijigae
gijigae / LogseqQC.js
Last active June 24, 2022 12:48
JavaScript code for Logseq Quick Capture
javascript:(function(){var d=document,w=window,f='logseq://x-callback-url/quickCapture',l=d.location,e=encodeURIComponent,p='?url='+e(l.href)+'&title='+e(d.title)+'&content='+e(w.getSelection?w.getSelection().toString():d.getSelection?d.getSelection():d.selection.createRange().text)+'&x-source=bm';a=function(){l.href=f+p};if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else{a()}void(0)})()
@gijigae
gijigae / logseq-wrap.json
Created June 20, 2022 03:03
Text Wrapper configuration file for Logseq, which have two additional options; embed iframe and embed video
{
"disabled": false,
"toolbar": true,
"wrap-cloze": {
"label": "Wrap with cloze",
"binding": "",
"template": " {{cloze $^}}",
"icon": "<svg t=\"1643261888324\" viewBox=\"0 0 1024 1024\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" p-id=\"5478\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"200\" height=\"200\"><defs><style type=\"text/css\"></style></defs><path d=\"M341.333333 396.8V320H170.666667v384h170.666666v-76.8H256V396.8zM682.666667 396.8V320h170.666666v384h-170.666666v-76.8h85.333333V396.8zM535.04 533.333333h40.96v-42.666666h-40.96V203.093333l92.16-24.746666-11.093333-40.96-102.4 27.306666-102.4-27.306666-11.093334 40.96 92.16 24.746666v287.573334H448v42.666666h44.373333v287.573334l-92.16 24.746666 11.093334 40.96 102.4-27.306666 102.4 27.306666 11.093333-40.96-92.16-24.746666z\" p-id=\"5479\" fill=\"#eeeeee\"></path></svg>"
},
"wrap-iframe": {