Last active
          December 18, 2021 11:51 
        
      - 
      
- 
        Save NO-ob/ed240ac8ccdb4a2775eb0857968c50e4 to your computer and use it in GitHub Desktop. 
Revisions
- 
        NO-ob revised this gist Dec 18, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ // @namespace https://gist.github.com/NO-ob/ed240ac8ccdb4a2775eb0857968c50e4/raw/5chImageInserter.user.js // @downloadURL https://gist.github.com/NO-ob/ed240ac8ccdb4a2775eb0857968c50e4/raw/5chImageInserter.user.js // @homepage https://gist.github.com/NO-ob/mangadex-scripts // @version 0.5 // @description Embeds images on 2/5chan reader sites // @author NO_ob // @include */r/*/*/* 
- 
        NO-ob revised this gist Dec 18, 2021 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,7 @@ // ==UserScript== // @name 2ch/5ch Image Inserter // @namespace https://gist.github.com/NO-ob/ed240ac8ccdb4a2775eb0857968c50e4/raw/5chImageInserter.user.js // @downloadURL https://gist.github.com/NO-ob/ed240ac8ccdb4a2775eb0857968c50e4/raw/5chImageInserter.user.js // @homepage https://gist.github.com/NO-ob/mangadex-scripts // @version 0.4 // @description Embeds images on 2/5chan reader sites 
- 
        NO-ob revised this gist Dec 18, 2021 . No changes.There are no files selected for viewing
- 
        NO-ob revised this gist Dec 18, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,7 @@ // @name 2ch/5ch Image Inserter // @namespace https://gist.github.com/NO-ob/ed240ac8ccdb4a2775eb0857968c50e4/raw/5chImageInserter.user.js // @homepage https://gist.github.com/NO-ob/mangadex-scripts // @version 0.4 // @description Embeds images on 2/5chan reader sites // @author NO_ob // @include */r/*/*/* 
- 
        NO-ob revised this gist Dec 18, 2021 . 1 changed file with 3 additions and 2 deletions.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,8 @@ // ==UserScript== // @name 2ch/5ch Image Inserter // @namespace https://gist.github.com/NO-ob/ed240ac8ccdb4a2775eb0857968c50e4/raw/5chImageInserter.user.js // @homepage https://gist.github.com/NO-ob/mangadex-scripts // @version 0.3 // @description Embeds images on 2/5chan reader sites // @author NO_ob // @include */r/*/*/* 
- 
        NO-ob revised this gist Dec 18, 2021 . 1 changed file with 11 additions and 2 deletions.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,6 +16,7 @@ // ==/UserScript== var useHREF = false; var insertRunning = false; var urlRegex; (function() { 'use strict'; (new MutationObserver(check)).observe(document, {childList: true, subtree: true}); @@ -46,11 +47,13 @@ function imageInsert(){ linkElements = document.querySelectorAll("div.res > a"); } else if (document.querySelectorAll("span.escaped > a").length > 0){ replaceTrimmedLinksInPosts("span.escaped"); useHREF = true; urlRegex = new RegExp("(?:[\?]+)(https?:\/\/[a-zA-Z0-9-_.\/+%?]+)","gm"); linkElements = document.querySelectorAll("span.escaped > a"); } else if (document.querySelectorAll("div.threadview_response_body > a").length > 0){ replaceTrimmedLinksInPosts("div.threadview_response_body"); useHREF=true; linkElements = document.querySelectorAll("div.threadview_response_body > a"); } console.log("Elements Found: " + linkElements.length); for (let i = 0; i < linkElements.length ; i++){ @@ -60,6 +63,12 @@ function imageInsert(){ linkElements[i].parentElement.appendChild(elem); } let url = useHREF ? linkElements[i].href : linkElements[i].innerHTML; if (urlRegex != null){ let matches = [...url.matchAll(urlRegex)]; if (matches.length > 0){ url = matches[0][1]; } } if (url.includes(":orig")){ url = url.replace(":orig",""); } 
- 
        NO-ob revised this gist Dec 16, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -66,7 +66,7 @@ function imageInsert(){ if (isImageURL(url)){ let tmpElem; console.log("Inserting: " + url); if(linkElements[i].innerHTML.toLowerCase().endsWith(".mp4")){ tmpElem = document.createElement("video"); tmpElem.setAttribute("src",url); tmpElem.setAttribute("class","scriptImage"); 
- 
        NO-ob revised this gist Dec 16, 2021 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -97,10 +97,11 @@ function isImageURL(url){ function replaceTrimmedLinksInPosts(postBodySelector){ document.querySelectorAll(postBodySelector).forEach((textSpan) => { let inner = textSpan.innerHTML; let re = new RegExp("(?<!h)(ttps?:\/\/[a-zA-Z0-9-_.\/+%?]+)", 'gm'); let matches = [...inner.matchAll(re)]; console.log(matches); matches.forEach((url) => { console.log("replacing " + url[0] + " in " + inner); inner = inner.replace(url[0],'<a class="'+(isImageURL(url[0])? 'image':'reply_link')+'" href="h'+ url[0]+'" target="_blank">h'+url[0]+'</a>'); }); textSpan.innerHTML = inner; 
- 
        NO-ob revised this gist Dec 16, 2021 . 1 changed file with 67 additions and 20 deletions.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,61 +1,108 @@ // ==UserScript== // @name 2ch/5ch Image Inserter // @namespace https://gist.github.com/NO-ob // @version 0.2 // @description Embeds images on 2/5chan reader sites // @author NO_ob // @include */r/*/*/* // @include */test/read.cgi/*/* // @include */read.php/*/* // @include */log/*/*/*/ // @include *.5ch.net/*/* // @include *.2ch.sc/test/read.cgi/*/* // @include none // @include document-idle // @icon https://5ch.net/favicon.ico // ==/UserScript== var useHREF = false; var insertRunning = false; (function() { 'use strict'; (new MutationObserver(check)).observe(document, {childList: true, subtree: true}); })(); function check(changes, observer) { if (!document.querySelector("div#scriptRan")) { if((document.querySelectorAll("dd > a").length > 0) || (document.querySelectorAll("div.res > a").length > 0) || (document.querySelectorAll("span.escaped > a").length > 0)|| (document.querySelectorAll("div.threadview_response_body > a").length > 0)) { if(!insertRunning){ imageInsert(); } } } } function imageInsert(){ insertRunning = true; let style = `.scriptImage {max-width: 100%;max-height: 100vh;width: auto;margin: auto;}` let styleSheet = document.createElement("style"); styleSheet.type = "text/css"; styleSheet.innerText = style; document.head.appendChild(styleSheet); let linkElements = null; if (document.querySelectorAll("dd > a").length > 0){ replaceTrimmedLinksInPosts("dd"); linkElements = document.querySelectorAll("dd > a"); } else if (document.querySelectorAll("div.res > a").length > 0) { replaceTrimmedLinksInPosts("div.res"); linkElements = document.querySelectorAll("div.res > a"); } else if (document.querySelectorAll("span.escaped > a").length > 0){ replaceTrimmedLinksInPosts("span.escaped"); linkElements = document.querySelectorAll("span.escaped > a") } else if (document.querySelectorAll("div.threadview_response_body > a").length > 0){ replaceTrimmedLinksInPosts("div.threadview_response_body"); useHREF=true; linkElements = document.querySelectorAll("div.threadview_response_body > a") } console.log("Elements Found: " + linkElements.length); for (let i = 0; i < linkElements.length ; i++){ if (i==0){ let elem = document.createElement("div"); elem.setAttribute("id", "scriptRan"); linkElements[i].parentElement.appendChild(elem); } let url = useHREF ? linkElements[i].href : linkElements[i].innerHTML; if (url.includes(":orig")){ url = url.replace(":orig",""); } if (isImageURL(url)){ let tmpElem; console.log("Inserting: " + url); if(linkElements[i].innerHTML.toLowerCase().includes(".mp4")){ tmpElem = document.createElement("video"); tmpElem.setAttribute("src",url); tmpElem.setAttribute("class","scriptImage"); tmpElem.controls = true; } else { tmpElem = document.createElement("img"); tmpElem.setAttribute("src",url); tmpElem.setAttribute("class","scriptImage"); } console.log(linkElements[i].innerHTML); linkElements[i].parentNode.replaceChild(tmpElem, linkElements[i]); } else { console.log("Skipping: " + url); } } console.log("Insert done!"); insertRunning = false; } function isImageURL(url){ return url.toLowerCase().includes(".png")|| url.toLowerCase().includes(".jpg")|| url.toLowerCase().includes(".jpeg")|| url.toLowerCase().includes(".mp4")|| url.toLowerCase().includes(".gif"); } function replaceTrimmedLinksInPosts(postBodySelector){ document.querySelectorAll(postBodySelector).forEach((textSpan) => { let inner = textSpan.innerHTML; let re = new RegExp("(?<!h)(ttps*:\/\/[a-zA-Z0-9-_.\/+%]+)", 'gm'); let matches = [...inner.matchAll(re)]; console.log(matches); matches.forEach((url) => { inner = inner.replace(url[0],'<a class="'+(isImageURL(url[0])? 'image':'reply_link')+'" href="h'+ url[0]+'" target="_blank">h'+url[0]+'</a>'); }); textSpan.innerHTML = inner; }); } 
- 
        NO-ob revised this gist Apr 2, 2021 . No changes.There are no files selected for viewing
- 
        NO-ob created this gist Apr 2, 2021 .There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,61 @@ // ==UserScript== // @name 2ch/5ch Image Inserter // @namespace https://gist.github.com/NO-ob // @version 0.1 // @description Embeds images on 2/5chan reader sites // @author NO_ob // @include */r/*/*/* // @include */test/read.cgi/*/* // @include */read.php/*/* // @include */log/*/*/*/ // @include none // @include document-idle // @icon https://5ch.net/favicon.ico // ==/UserScript== (function() { 'use strict'; if (document.querySelectorAll("dd > a").length > 0 || (document.querySelectorAll("div.res > a").length > 0)){ imageInsert(); } else { (new MutationObserver(check)).observe(document, {childList: true, subtree: true}); } })(); function check(changes, observer) { if((document.querySelectorAll("dd > a").length > 0) || (document.querySelectorAll("div.res > a").length > 0) || (document.querySelectorAll("span.escaped > a").length > 0)) { observer.disconnect(); imageInsert(); } } function imageInsert(){ let style = `.scriptImage {max-width: 100%;max-height: 100vh;width: auto;margin: auto;}` let styleSheet = document.createElement("style"); styleSheet.type = "text/css"; styleSheet.innerText = style; document.head.appendChild(styleSheet); let linkElements = null; if (document.querySelectorAll("dd > a").length > 0){ linkElements = document.querySelectorAll("dd > a"); } else if (document.querySelectorAll("div.res > a").length > 0) { linkElements = document.querySelectorAll("div.res > a"); } else if (document.querySelectorAll("span.escaped > a").length > 0){ linkElements = document.querySelectorAll("span.escaped > a") } console.log("Elements Found: " + linkElements.length); for (let i = 0; i < linkElements.length ; i++){ if (linkElements[i].innerHTML.toLowerCase().includes("png")|| linkElements[i].innerHTML.toLowerCase().includes("jpg")|| linkElements[i].innerHTML.toLowerCase().includes("jpeg")|| linkElements[i].innerHTML.toLowerCase().includes("gif")){ console.log("Inserting: " + linkElements[i].innerHTML); let tmpElem = document.createElement("img"); tmpElem.setAttribute("src",linkElements[i].innerHTML); tmpElem.setAttribute("class","scriptImage"); linkElements[i].parentNode.replaceChild(tmpElem, linkElements[i]); } else { console.log("Skipping: " + linkElements[i].innerHTML); } } console.log("Script done!"); }