// ==UserScript== // @name Greasyfork Search with Sleazyfork Results include // @name:zh-CN 大人的Greasyfork // @name:zh-TW 大人的Greasyfork // @name:ja 大人のGreasyfork // @namespace hoothin // @version 1.5 // @description Merge adult results of sleazyfork into greasyfork when the script is no longer anonymously available, add rating score and version for scripts then // @description:zh-CN 在Greasyfork的搜索结果中添加Sleazyfork上的成人脚本,增加评分与版本号,并在访问匿名不可用脚本时跳转至Sleazyfork // @description:zh-TW 在Greasyfork的搜索結果中添加Sleazyfork上的成人腳本,增加評分與版本號,並在訪問匿名不可用腳本時跳轉至Sleazyfork // @description:ja 脚本付けるSleazyfork上の成人脚本検索結果からGreasyfork、脚本付ける採点とバージョン番号を訪問匿名利用できない脚本にジャンプからSleazyfork // @author hoothin // @include http*://greasyfork.org/* // @include http*://www.greasyfork.org/* // @include http*://sleazyfork.org/* // @include http*://www.sleazyfork.org/* // @grant GM_xmlhttpRequest // @grant GM_setValue // @grant GM_getValue // @grant GM_registerMenuCommand // @grant GM_notification // @grant GM.xmlhttpRequest // @grant GM.setValue // @grant GM.getValue // @grant GM.registerMenuCommand // @grant GM.notification // @connect greasyfork.org // @connect sleazyfork.org // @contributionURL https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=rixixi@sina.com&item_name=Greasy+Fork+donation // @contributionAmount 1 // @downloadURL none // ==/UserScript== (function() { 'use strict'; var _GM_xmlhttpRequest,_GM_registerMenuCommand,_GM_notification; if(typeof GM_xmlhttpRequest!='undefined'){ _GM_xmlhttpRequest=GM_xmlhttpRequest; }else if(typeof GM!='undefined' && typeof GM.xmlhttpRequest!='undefined'){ _GM_xmlhttpRequest=GM.xmlhttpRequest; } if(typeof GM_registerMenuCommand!='undefined'){ _GM_registerMenuCommand=GM_registerMenuCommand; }else if(typeof GM!='undefined' && typeof GM.registerMenuCommand!='undefined'){ _GM_registerMenuCommand=GM.registerMenuCommand; } if(typeof GM_notification!='undefined'){ _GM_notification=GM_notification; }else if(typeof GM!='undefined' && typeof GM.notification!='undefined'){ _GM_notification=GM.notification; } if(typeof _GM_xmlhttpRequest=='undefined')_GM_xmlhttpRequest=(f)=>{}; if(typeof _GM_registerMenuCommand=='undefined')_GM_registerMenuCommand=(s,f)=>{}; if(typeof _GM_notification=='undefined')_GM_notification=(s)=>{}; var storage={ supportGM: typeof GM_getValue=='function' && typeof GM_getValue('a','b')!='undefined', supportGMPromise: typeof GM!='undefined' && typeof GM.getValue=='function' && typeof GM.getValue('a','b')!='undefined', mxAppStorage:(function(){ try{ return window.external.mxGetRuntime().storage; }catch(e){ }; })(), operaUJSStorage:(function(){ try{ return window.opera.scriptStorage; }catch(e){ }; })(), setItem:function(key,value){ if(this.operaUJSStorage){ this.operaUJSStorage.setItem(key,value); }else if(this.mxAppStorage){ this.mxAppStorage.setConfig(key,value); }else if(this.supportGM){ GM_setValue(key,value); }else if(this.supportGMPromise){ GM.setValue(key,value); }else if(window.localStorage){ window.localStorage.setItem(key,value); }; }, getItem:function(key,cb){ var value; if(this.operaUJSStorage){ value=this.operaUJSStorage.getItem(key); }else if(this.mxAppStorage){ value=this.mxAppStorage.getConfig(key); }else if(this.supportGM){ value=GM_getValue(key); }else if(this.supportGMPromise){ value=GM.getValue(key).then(v=>{cb(v)}); return; }else if(window.localStorage){ value=window.localStorage.getItem(key); }; cb(value); }, }; if(document.querySelector('span.sign-in-link')){ var otherSite=/greasyfork\.org/.test(location.hostname)?"sleazyfork":"greasyfork"; if(/scripts\/\d+/.test(location.href)){ if(!document.querySelector("#script-info") && (otherSite == "greasyfork" || document.querySelector("div.width-constraint>section>p>a").href.indexOf("sign_in")!=-1)){ location.href=location.href.replace(/\/\/([^\.]+\.)?(greasyfork|sleazyfork)\.org/,"//$1"+otherSite+"\.org"); } }else if(/\/(scripts|users)(\/|.*(\?|&)q=|.*\?set=)/.test(location.href)){ _GM_xmlhttpRequest({ method: 'GET', url: location.href.replace(/\/\/([^\.]+\.)?(greasyfork|sleazyfork)\.org/,"//$1"+otherSite+"\.org"), onload: function(result) { var doc = null; try { doc = document.implementation.createHTMLDocument(''); doc.documentElement.innerHTML = result.responseText; } catch (e) { console.log('parse error'); } if (!doc) { return; } var l = doc.querySelector('ol.script-list'); if (l) { var ml = document.querySelector('ol.script-list'); if(!ml){ ml=document.createElement("ol"); ml.setAttribute("class","script-list"); var list=document.querySelector('.sidebarred-main-content'); var ps=list.querySelectorAll("p"); for(let i=0;i`; storage.getItem("GeasyforkBullshit",v=>{ bullshit=v; if(!bullshit)bullshit=bullshit_o; if(/greasyfork\.org\/.*\/scripts\/23840[^\/]*$/.test(location.href)){ var p=document.createElement("p"),_bullshit; p.style.width="90%"; p.innerHTML="Filter RegExp string Config"; var okBtn=p.querySelector("#ok"); var resetBtn=p.querySelector("#reset"); var filterTextarea=document.createElement("pre"); var prettifyScript=document.createElement("script"); prettifyScript.src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js?lang=js&skin=sunburst"; document.head.appendChild(prettifyScript); filterTextarea.contentEditable="true"; filterTextarea.className="prettyprint lang-js"; filterTextarea.style.whiteSpace="pre-wrap"; filterTextarea.style.overflowWrap="break-word"; filterTextarea.innerHTML=bullshit; var additionalInfo=document.querySelector("#additional-info"); p.appendChild(filterTextarea); additionalInfo.insertBefore(p,additionalInfo.firstChild); prettifyScript.onload=()=>{PR.prettyPrint();}; okBtn.onclick=()=>{ _bullshit=filterTextarea.innerText; storage.setItem("GeasyforkBullshit", _bullshit); alert("Saved"); //_GM_notification("Saved"); }; resetBtn.onclick=()=>{ storage.setItem("GeasyforkBullshit", bullshit_o); alert("Reset over"); location.reload(); //_GM_notification("Reset over"); }; } initFilter(); }); function addScore(script){ var separator=script.querySelector('h2>span.name-description-separator'); var description=script.querySelector('h2>span.description'); if(separator){ var score=document.createElement("strong"); score.style.color="#e09015"; score.innerHTML=script.dataset.scriptRatingScore; separator.parentNode.insertBefore(score,separator); } if(description){ count(script); var scriptHref=script.querySelector('h2>a').href; let version=script.dataset.scriptVersion; let format=script.dataset.scriptLanguage; description.innerHTML+=`Ver.${version}
Install
`; var installArea=description.querySelector("#install-area"); let installLink=installArea.querySelector(".install-link"); let checkInfo=installArea.querySelector(".install-help-link"); script.onmouseenter=e=>{ checkInfo.appendChild(refreshIcon); }; script.onmouseleave=e=>{ checkInfo.removeChild(refreshIcon); }; checkInfo.onclick=()=>{ _GM_xmlhttpRequest({ method: 'GET', url: scriptHref.replace(/(.*)-.*/,"$1.json"), onload: function(result) { var data = null; try { data = JSON.parse(result.responseText); } catch (e) { console.log('parse error'); } if(data){ let setInfo=info=>{ if(info.installed){ if(parseFloat(info.version) < parseFloat(version)){ installLink.innerHTML="Update to version "+version; }else if(parseFloat(info.version) > parseFloat(version)){ installLink.innerHTML="Downgrade to version "+version; }else{ installLink.innerHTML="Reinstall version "+version; } if(!info.enabled){ installLink.style.backgroundColor="#6a6a6a"; }else{ installLink.style.backgroundColor=""; } }else{ installLink.innerHTML="Install version "+version; } }; if(window.external.Tampermonkey){ window.external.Tampermonkey.isInstalled(data.name, data.namespace, e=>{ setInfo(e); }); }else if(window.external.Violentmonkey){ window.external.Violentmonkey.isInstalled(data.name, data.namespace).then(e=>{ setInfo(e); }); } } } }); }; if(!window.external.Tampermonkey && !window.external.Violentmonkey){ checkInfo.style.display="none"; } } } function count(script){ if(!inUserPage)return; var dailySpan=script.querySelector("dd.script-list-daily-installs>span"); if(!dailySpan)return; var dailyCount=parseInt(dailySpan.innerHTML.replace(/[^\d\.\-]/g,"")); var totalCount=parseInt(script.querySelector("dd.script-list-total-installs>span").innerHTML.replace(/[^\d]/g,"")); var goodCount=parseInt(script.querySelector("dd.script-list-ratings>span>.good-rating-count").innerHTML.replace(/[^\d]/g,"")); var okCount=parseInt(script.querySelector("dd.script-list-ratings>span>.ok-rating-count").innerHTML.replace(/[^\d]/g,"")); var badCount=parseInt(script.querySelector("dd.script-list-ratings>span>.bad-rating-count").innerHTML.replace(/[^\d]/g,"")); goodRating.innerHTML=parseInt(goodRating.innerHTML)+goodCount; okRating.innerHTML=parseInt(okRating.innerHTML)+okCount; badRating.innerHTML=parseInt(badRating.innerHTML)+badCount; totalInstalls.innerHTML=parseInt(totalInstalls.innerHTML)+totalCount; dailyInstalls.innerHTML=parseInt(dailyInstalls.innerHTML)+dailyCount; ratingSpan.style.display=totalInstalls.style.display=dailyInstalls.style.display=""; } _GM_registerMenuCommand("Configure the Filter", ()=>{ location.href="https://greasyfork.org/scripts/23840#additional-info"; /*var _bullshit=window.prompt("Configure the Filter", bullshit); if(_bullshit == ""){ bullshit=bullshit_o; storage.setItem("GeasyforkBullshit", bullshit); location.reload(); }else if(_bullshit != null){ bullshit=_bullshit; storage.setItem("GeasyforkBullshit", bullshit); location.reload(); }*/ }); if(inUserPage){ var ratingSpan=document.createElement("span"); goodRating=document.createElement("span"); okRating=document.createElement("span"); badRating=document.createElement("span"); totalInstalls=document.createElement("span"); dailyInstalls=document.createElement("span"); goodRating.className="good-rating-count"; okRating.className="ok-rating-count"; badRating.className="bad-rating-count"; totalInstalls.className="good-rating-count"; dailyInstalls.className="good-rating-count"; ratingSpan.appendChild(goodRating); ratingSpan.appendChild(okRating); ratingSpan.appendChild(badRating); document.querySelector("#script-list-sort ul>li:nth-child(1)").appendChild(dailyInstalls); document.querySelector("#script-list-sort ul>li:nth-child(2)").appendChild(totalInstalls); document.querySelector("#script-list-sort ul>li:nth-child(3)").appendChild(ratingSpan); ratingSpan.style.display=totalInstalls.style.display=dailyInstalls.style.display="none"; goodRating.innerHTML=okRating.innerHTML=badRating.innerHTML=totalInstalls.innerHTML=dailyInstalls.innerHTML="0"; } function initFilter(){ var enableFilter; if(sortDiv){ storage.getItem("disableFilter",v=>{ enableFilter=!v; var switchFilter=document.createElement("div"); var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver; var observer = new MutationObserver(function(records){ records.map(function(record) { for(var i=0;i.width-constraint .sidebarred-main-content"), option); var scriptList=document.querySelector("#browse-script-list,#user-script-list,ol.script-list"); if(scriptList)observer.observe(scriptList, option); var scripts=document.querySelectorAll('ol.script-list>li'); for(let i=0;ispan{ position: absolute; top: 4px; right: 2px; pointer-events: none; font-weight: 500; } #script-list-sort li>span:lang(ar), #script-list-sort li>span:lang(he), #script-list-sort li>span:lang(ug){ right: unset; left: 2px; } #script-list-sort li>span>span{ margin: 0 0 0 2px; } .script-list>li .list-install-area{ display: none; float: right; position: relative; } .script-list>li:hover .list-install-area { display: block; } @-webkit-keyframes spin { from { -webkit-transform: rotate(0deg); } to { -webkit-transform: rotate(360deg); } } @keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } } .refresh-info:hover>span { display: block; -webkit-animation: spin 1s linear 1s 5 alternate; animation: spin 1s linear infinite; }`; style.type = 'text/css'; document.querySelector('head').appendChild(style); var bullshitReg=new RegExp(bullshit,"i"); var filterName="Enable Filter",filteredNum=0; var filter=function(t){ [].forEach.call(t.querySelectorAll('article>h2'), function(item) { if(bullshitReg.test(item.innerText.replace("\n"," "))){ item.parentNode.parentNode.classList.add('filtered'); filteredNum++; } }); }; if(enableFilter)filter(document); switchFilter.innerHTML=''; var switchFilterCheckbox=switchFilter.querySelector('#switchFilter'); var switchFilterLabel=switchFilterCheckbox.nextSibling; switchFilterCheckbox.checked=enableFilter; switchFilterCheckbox.onclick=function(){ if(enableFilter){ [].forEach.call(document.querySelectorAll('li.filtered'), function(item) { item.classList.remove('filtered'); }); switchFilterLabel.innerHTML=filterName; }else{ filteredNum=0; filter(document); switchFilterLabel.innerHTML=filterName+' ('+filteredNum+' filtered)'; } storage.setItem("disableFilter",enableFilter); enableFilter=!enableFilter; }; sortDiv.insertBefore(switchFilter,sortDiv.firstChild); }); } } })();