Created
January 11, 2023 16:15
-
-
Save jsEveryDay/25691b0912e046a3357378da90b57914 to your computer and use it in GitHub Desktop.
userAsset
This 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 characters
argTest.js text/javascript | |
document.addEventListener('DOMContentLoaded',function(){alert('{{1}}'),console.warn('{{1}}')}); | |
///contextMenuMovies.js | |
const cssSelector='{{1}}';const Q={MovieName:()=>{return self},checkStr:(val)=>{return typeof val==='string' && val.length>0},inLineOnClick:(domID)=>{try{Q[domID]()}catch(err){Q.err(err)}finally{Q.l('Success')}},getMovieName(movieString){const baseName=movieString.trim().replace(/\.(avi|mkv|mpeg|mpg|mov|mp4|m4v)$/i,'');let movie=baseName.match(/(.*?)(directors(.?)cut|480p|720p|1080p|dvdrip|xvid|cd[0-9]|bluray|dvdscr|brrip|divx|S[0-9]{1,3}E[0-9]{1,3}|Season[\s,0-9]{1,4}|[\{\(\[]?[0-9]{4}).*/i);if (movie && movie[1]){movie=movie[1].replace(/\./g,' ').trim()}else{movie=baseName}movie=movie.substring(movie.indexOf('-') + 1);return movie},findDownloads:()=>{const name=Q.MovieName.replace(' ','+');const url=`http://scene-rls.net/?s=${name}&submit=Find`;window.open(url,'_blank')},youTubeSearch:()=>{const name=Q.MovieName.replace(' ','+');const url=`https://www.youtube.com/results?search_query=${name}+trailer`;window.open(url,'_blank')},copy2clip:()=>{navigator.clipboard.writeText(Q.MovieName)},handler(e){let name;Q.checkStr(e.target.textContent) ? name=e.target.textContent:Q.err(e.target.textContent);Q.MovieName=Q.getMovieName(name)},err(logString){JSON.stringify(logString);return true},l :(any)=>{console.log(`${any}`)}};const __mCfg={menu:void 0,menuState:false,startListening:()=>{const titles=document.querySelectorAll(cssSelector);for (let title of titles){title.addEventListener("contextmenu",e=>{e.preventDefault(),__mCfg.menuEvent(e),e.stopPropagation()},!1)};document.addEventListener("click",__mCfg.clsM,false)},startMenu:()=>{let b;if(window.hasOwnProperty("cxItems") && window.hasOwnProperty("cxClick")){let h=document.head;let css=document.createElement('style');css.textContent=`cxmenu{position:absolute;background-color:#1c1c1c;color:#cacaca;border-radius:.6em;line-height:2em;display:none;top:0;left:0;width:fit-content}cxmenu.open{display:block}cxmenu ul{padding:0;margin:.5em .2em}cxmenu ul li{cursor:pointer;overflow:hidden;padding:0 1em}cxmenu ul li:hover{background-image:linear-gradient(#6eaa5c,#265326);border-radius:.6em}`;h.appendChild(css);b=document.createElement('cxmenu');b.style["z-index"]=10e5;b.appendChild(document.createElement('ul'));cxItems.map(k=>{let item=document.createElement('li');item.id=k.id;let textnode=document.createTextNode(k.title);item.appendChild(textnode);item.setAttribute('onclick','cxClick(this.id)');b.firstChild.appendChild(item)});document.body.appendChild(b);__mCfg.menu=document.getElementsByTagName('cxmenu').item(0)}else{console.warn("Please write a function handler for clicks or provide cxItems object like:");console.warn([{title:"Empty",id:"empty"}])}},menuEvent:(b)=>{if(!__mCfg.menu){__mCfg.startMenu()};if(!__mCfg.menuState){__mCfg.opnM(b)}else{__mCfg.clsM()}},opnM:(b)=>{__mCfg.menu.style.display="block",__mCfg.menu.style.top=b.pageY + "px",__mCfg.menu.style.left=b.pageX + "px",Q.handler(b)},clsM:()=>{__mCfg.menuState=false,__mCfg.menu.style.display="none"}};window.cxClick=e=>Q.inLineOnClick(e),cxItems=[{title:"Search Scene-RLS",id:"findDownloads"},{title:"YouTube Trailer",id:"youTubeSearch"},{title:"Copy Title",id:"copy2clip"}],onload=__mCfg.startListening; | |
///amazonUsedItems.js | |
(function(){if(!document.location.href.startsWith('https://www.amazon.com/s?'))return!1;const domReady=()=>{const customCSS=document.createElement('style');customCSS.textContent='span.usedShit{display:block;background-color:#B12704;color:white;text-indent:1em;margin-bottom:-10px;}';document.head.appendChild(customCSS);function parsePrice(priceString){const price=priceString.replace(/[^\d\.]*/g,'');const final=parseInt(price);return final};function calcPercentage(newPrice,usedPrice){if(usedPrice<newPrice){const division=1-(usedPrice/newPrice);if(parseInt(division*100)<20){return!1}else{return parseInt(division*100)}}else{return!1}};const domMain=document.createElement('a');domMain.className='a-link-normal';const usedShit=document.createElement("span");usedShit.className='usedShit';domMain.appendChild(usedShit);let resultsDom=document.body.querySelectorAll('div.s-result-list.s-search-results > [data-index]');resultsDom.forEach(function(el,i){const old='div.a-color-secondary > span.a-color-base';const brandNew='span.a-price > span.a-offscreen';if(el.querySelector(old)!=null&&el.querySelector(brandNew)!=null){const usedPrice=parsePrice(el.querySelector(old).textContent);const newPrice=parsePrice(el.querySelector(brandNew).textContent);const difference=calcPercentage(newPrice,usedPrice);if(!difference)return;const reuseDom=domMain.cloneNode(!0);const differenceStr=`${difference}%`;reuseDom.firstChild.style.width=differenceStr;reuseDom.firstChild.appendChild(document.createTextNode(differenceStr));el.prepend(reuseDom)}else{return}})};if(document.readyState==='loading'){document.addEventListener('DOMContentLoaded',domReady)}else{domReady()}})(); | |
///replaceElAttrwithElAttr.js | |
document.addEventListener('DOMContentLoaded',function(){const sel=document.querySelectorAll('{{1}}');Object.keys(sel).map(key => (sel[key].setAttribute('{{2}}', sel[key].getAttribute('{{3}}'))))}); | |
///addAttribute.js | |
document.addEventListener('DOMContentLoaded',function(){document.querySelectorAll('{{1}}').forEach(el => el.setAttribute('{{2}}','{{3}}'))}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment