大人的Greasyfork

在Greasyfork的搜索结果中添加Sleazyfork上的成人脚本,增加评分与版本号,并在访问匿名不可用脚本时跳转至Sleazyfork

当前为 2021-12-31 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Greasyfork Search with Sleazyfork Results include
  3. // @name:zh-CN 大人的Greasyfork
  4. // @name:zh-TW 大人的Greasyfork
  5. // @name:ja 大人のGreasyfork
  6. // @namespace hoothin
  7. // @version 0.99
  8. // @description Merge adult results of sleazyfork into greasyfork when the script is no longer anonymously available, add rating score and version for scripts then
  9. // @description:zh-CN 在Greasyfork的搜索结果中添加Sleazyfork上的成人脚本,增加评分与版本号,并在访问匿名不可用脚本时跳转至Sleazyfork
  10. // @description:zh-TW 在Greasyfork的搜索結果中添加Sleazyfork上的成人腳本,增加評分與版本號,並在訪問匿名不可用腳本時跳轉至Sleazyfork
  11. // @description:ja 脚本付けるSleazyfork上の成人脚本検索結果からGreasyfork、脚本付ける採点とバージョン番号を訪問匿名利用できない脚本にジャンプからSleazyfork
  12. // @author hoothin
  13. // @include http*://greasyfork.org/*
  14. // @include http*://www.greasyfork.org/*
  15. // @include http*://sleazyfork.org/*
  16. // @include http*://www.sleazyfork.org/*
  17. // @grant GM_xmlhttpRequest
  18. // @grant GM_setValue
  19. // @grant GM_getValue
  20. // @grant GM_registerMenuCommand
  21. // @connect greasyfork.org
  22. // @connect sleazyfork.org
  23. // @contributionURL https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=rixixi@sina.com&item_name=Greasy+Fork+donation
  24. // @contributionAmount 1
  25. // ==/UserScript==
  26.  
  27. (function() {
  28. 'use strict';
  29. if(document.querySelector('span.sign-in-link')){
  30. var otherSite=/greasyfork\.org/.test(location.hostname)?"sleazyfork":"greasyfork";
  31. if(/scripts\/\d+/.test(location.href)){
  32. if(!document.querySelector("#script-info") && (otherSite == "greasyfork" || document.querySelector("div.width-constraint>section>p>a").href.indexOf("sign_in")!=-1)){
  33. location.href=location.href.replace(/\/\/([^\.]+\.)?(greasyfork|sleazyfork)\.org/,"//$1"+otherSite+"\.org");
  34. }
  35. }else if(/\/(scripts|users)(\/|.*(\?|&)q=|.*\?set=)/.test(location.href)){
  36. GM_xmlhttpRequest({
  37. method: 'GET',
  38. url: location.href.replace(/\/\/([^\.]+\.)?(greasyfork|sleazyfork)\.org/,"//$1"+otherSite+"\.org"),
  39. onload: function(result) {
  40. var doc = null;
  41. try {
  42. doc = document.implementation.createHTMLDocument('');
  43. doc.documentElement.innerHTML = result.responseText;
  44. }
  45. catch (e) {
  46. console.log('parse error');
  47. }
  48. if (!doc) {
  49. return;
  50. }
  51. var l = doc.querySelector('ol.script-list');
  52. if (l) {
  53. var ml = document.querySelector('ol.script-list');
  54. if(!ml){
  55. ml=document.createElement("ol");
  56. ml.setAttribute("class","script-list");
  57. var list=document.querySelector('.sidebarred-main-content');
  58. var ps=list.querySelectorAll("p");
  59. for(let i=0;i<ps.length;i++){
  60. let p=ps[i];
  61. list.removeChild(p);
  62. }
  63. list.appendChild(ml);
  64. }
  65. var scs=l.querySelectorAll("li");
  66. if(scs){
  67. for(let i=0;i<scs.length;i++){
  68. let sc=scs[i];
  69. if(!ml.querySelector("li[data-script-id='"+sc.dataset.scriptId+"']")){
  70. //addScore(sc);
  71. ml.appendChild(sc);
  72. }
  73. }
  74. }
  75. }
  76. },
  77. onerror: function(e) {
  78. console.log(e);
  79. }
  80. });
  81. }
  82. }
  83. function addScore(script){
  84. var separator=script.querySelector('h2>span.name-description-separator');
  85. var description=script.querySelector('h2>span.description');
  86. if(separator){
  87. var score=document.createElement("strong");
  88. score.style.color="#e09015";
  89. score.innerHTML=script.dataset.scriptRatingScore;
  90. separator.parentNode.insertBefore(score,separator);
  91. }
  92. if(description){
  93. var scriptHref=script.querySelector('h2>a').href;
  94. let version=script.dataset.scriptVersion;
  95. let format=script.dataset.scriptLanguage;
  96. description.innerHTML+=`<strong>Ver.${version}</strong>
  97. <div id="install-area" class="list-install-area">
  98. <a class="install-link" data-install-format="${format}" data-ping-url href="${scriptHref.replace(/\.org\/.*\/scripts\//,".org/scripts/")}/code/script.user.js">Install</a><a style="cursor:pointer;" class="install-help-link refresh-info" title="Check status" rel="nofollow"></a>
  99. </div><div id="installation-instructions-modal-js" aria-hidden="true"><p class="installation-instructions-modal-content-bypass"><a href="#"></a></p></div><div id="installation-instructions-modal-css" aria-hidden="true"><p class="installation-instructions-modal-content-bypass"><a href="#"></a></p></div>`;
  100. var installArea=description.querySelector("#install-area");
  101. let installLink=installArea.querySelector(".install-link");
  102. let checkInfo=installArea.querySelector(".install-help-link");
  103. script.onmouseenter=e=>{
  104. checkInfo.appendChild(refreshIcon);
  105. };
  106. script.onmouseleave=e=>{
  107. checkInfo.removeChild(refreshIcon);
  108. };
  109. checkInfo.onclick=()=>{
  110. GM_xmlhttpRequest({
  111. method: 'GET',
  112. url: scriptHref,
  113. onload: function(result) {
  114. var doc = null;
  115. try {
  116. doc = document.implementation.createHTMLDocument('');
  117. doc.documentElement.innerHTML = result.responseText;
  118. }
  119. catch (e) {
  120. console.log('parse error');
  121. }
  122. if (!doc) {
  123. return;
  124. }
  125. var installInfo=doc.querySelector("#install-area>.install-link");
  126. if(installInfo){
  127. let setInfo=info=>{
  128. if(info.installed){
  129. if(parseFloat(info.version) < parseFloat(version)){
  130. installLink.innerHTML="Update to version "+version;
  131. }else if(parseFloat(info.version) > parseFloat(version)){
  132. installLink.innerHTML="Downgrade to version "+version;
  133. }else{
  134. installLink.innerHTML="Reinstall version "+version;
  135. }
  136.  
  137. if(!info.enabled){
  138. installLink.style.backgroundColor="#6a6a6a";
  139. }else{
  140. installLink.style.backgroundColor="";
  141. }
  142. }else{
  143. installLink.innerHTML="Install version "+version;
  144. }
  145. };
  146. if(window.external.Tampermonkey){
  147. window.external.Tampermonkey.isInstalled(installInfo.dataset.scriptName, installInfo.dataset.scriptNamespace, e=>{
  148. setInfo(e);
  149. });
  150. }else if(window.external.Violentmonkey){
  151. window.external.Violentmonkey.isInstalled(installInfo.dataset.scriptName, installInfo.dataset.scriptNamespace).then(e=>{
  152. setInfo(e);
  153. });
  154. }
  155. }
  156. }
  157. });
  158. };
  159. if(!window.external.Tampermonkey && !window.external.Violentmonkey){
  160. checkInfo.style.display="none";
  161. }
  162. }
  163. }
  164. var bullshit=GM_getValue("GeasyforkBullshit"),bullshit_o="vip.*视频|网课|刷课|(mooc|考试|学习).*(答题|挂机)|(网盘|網盤|云盘).*(vip|直链)|优惠劵|AntiGame|split|Agar|\.io(\b|:|\/|\.|$)|ExtencionRipXChetoMalo|AposBot|DFxLite|ZTx-Lite|AposFeedingBot|AposLoader|Blah Blah|Orc Clan Script|Astro\s*Empires|^\s*Attack|^\s*Battle|BiteFight|Blood\s*Wars|Bots|Bots4|Brawler|\bBvS\b|Business\s*Tycoon|Castle\s*Age|City\s*Ville|Comunio|Conquer\s*Club|CosmoPulse|Dark\s*Orbit|Dead\s*Frontier|\bDOA\b|DotD|Dossergame|Dragons\s*of\s*Atlantis|Dugout|\bDS[a-z]+\n|Empire\s*Board|eRep(ublik)?|Epic.*War|ExoPlanet|Falcon Tools|Feuerwache|Farming|FarmVille|Fightinfo|Frontier\s*Ville|Ghost\s*Trapper|Gladiatus|Goalline|Gondal|Grepolis|Hobopolis|\bhwm(\b|_)|Ikariam|\bIT2\b|Jellyneo|Kapi\s*Hospital|Kings\s*Age|Kingdoms?\s*of|knastv(ö|oe)gel|Knight\s*Fight|\b(Power)?KoC(Atta?ck)?\b|\bKOL\b|Kongregate|Last\s*Emperor|Legends?\s*of|Light\s*Rising|Lockerz|\bLoU\b|Mafia\s*(Wars|Mofo)|Menelgame|Mob\s*Wars|Mouse\s*Hunt|Molehill\s*Empire|NeoQuest|MyFreeFarm|Neopets|Nemexia|\bOGame\b|Ogar(io)?|Pardus|Pennergame|Pigskin\s*Empire|PlayerScripts|Popmundo|Po?we?r\s*(Bot|Tools)|PsicoTSI|Ravenwood|Schulterglatze|slitheriogameplay|SpaceWars|\bSW_[a-z]+\n|\bSnP\b|The\s*Crims|The\s*West|Travian|Treasure\s*Isl(and|e)|Tribal\s*Wars|TW.?PRO|Vampire\s*Wars|War\s*of\s*Ninja|West\s*Wars|\bWoD\b|World\s*of\s*Dungeons|wtf\s*battles|Wurzelimperium";
  165. if(!bullshit)bullshit=bullshit_o;
  166. GM_registerMenuCommand("Configure the Filter", ()=>{
  167. var _bullshit=window.prompt("Configure the Filter", bullshit);
  168. if(_bullshit == ""){
  169. bullshit=bullshit_o;
  170. GM_setValue("GeasyforkBullshit", bullshit);
  171. location.reload();
  172. }else if(_bullshit != null){
  173. bullshit=_bullshit;
  174. GM_setValue("GeasyforkBullshit", bullshit);
  175. location.reload();
  176. }
  177. });
  178. var sortDiv=document.querySelector("#script-list-sort"),refreshIcon=document.createElement("span");
  179. refreshIcon.innerHTML=`<svg class="icon" style="width: 1em;height: 1em;vertical-align: middle;fill: currentColor;overflow: hidden;" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2274"><path d="M981.314663 554.296783a681.276879 681.276879 0 0 1-46.986468 152.746388q-105.706098 230.734238-360.983096 242.19829a593.06288 593.06288 0 0 1-228.689008-33.853939v-1.022615l-31.808709 79.979258a55.759429 55.759429 0 0 1-20.506122 22.551352 40.043451 40.043451 0 0 1-21.04434 5.382184 51.076928 51.076928 0 0 1-19.483507-5.382184 95.210839 95.210839 0 0 1-13.347817-7.158305 52.314831 52.314831 0 0 1-5.382184-4.628679L71.671707 731.908862a57.427906 57.427906 0 0 1-7.158305-21.528737 46.932646 46.932646 0 0 1 1.022615-17.438277 35.952991 35.952991 0 0 1 7.158305-13.347816 74.435608 74.435608 0 0 1 10.279972-10.279972 60.495751 60.495751 0 0 1 11.248765-7.373593 50.431066 50.431066 0 0 1 8.18092-3.606063 6.189512 6.189512 0 0 0 3.067845-1.776121l281.003839-74.866183a91.497132 91.497132 0 0 1 35.899168-2.583448 122.337047 122.337047 0 0 1 22.174599 6.404799 21.528737 21.528737 0 0 1 12.325202 12.325202 76.157907 76.157907 0 0 1 4.628679 14.854829 47.63233 47.63233 0 0 1 0 14.370431 55.167388 55.167388 0 0 1-2.04523 10.764369 10.764368 10.764368 0 0 0-1.022615 3.606063l-32.831324 79.979258a677.50935 677.50935 0 0 0 164.264262 39.505232q77.395809 7.696523 131.809692-3.606063a358.507291 358.507291 0 0 0 101.023598-36.921784 381.27393 381.27393 0 0 0 73.951211-50.753997 352.64071 352.64071 0 0 0 48.708767-55.382676 410.391547 410.391547 0 0 0 26.910921-41.550462c3.767529-7.481236 6.673908-13.616926 8.719139-18.460892zM40.885614 449.667121a685.69027 685.69027 0 0 1 63.563595-176.427998q118.0313-212.273346 374.330913-207.160271a571.803252 571.803252 0 0 1 207.160271 39.989629l33.853939-78.956643A75.619688 75.619688 0 0 1 735.187378 9.189165a37.67529 37.67529 0 0 1 15.393047-8.234742 42.303968 42.303968 0 0 1 14.854829-0.538219 47.578509 47.578509 0 0 1 13.347817 3.606064 102.907362 102.907362 0 0 1 11.302586 6.13569 49.569917 49.569917 0 0 1 6.673909 4.628678l3.067845 3.067845 154.84544 276.913379a81.970666 81.970666 0 0 1 6.13569 22.712817 46.986468 46.986468 0 0 1-1.022615 17.438277 32.293105 32.293105 0 0 1-7.696523 13.347817 69.322533 69.322533 0 0 1-10.764369 9.741753 92.142994 92.142994 0 0 1-11.302587 6.673909l-8.18092 4.09046a7.104483 7.104483 0 0 1-3.067845 1.022615l-283.049068 67.546412a112.003254 112.003254 0 0 1-46.125319-1.022615c-11.571696-3.390776-19.160576-8.019454-22.551352-13.832214a41.173709 41.173709 0 0 1-5.382184-21.04434 97.256069 97.256069 0 0 1 1.291724-17.438277 24.381295 24.381295 0 0 1 3.067845-8.234742L600.632773 296.81309a663.730958 663.730958 0 0 0-164.102797-43.057474q-77.987849-9.203535-131.809692 0a348.227319 348.227319 0 0 0-101.292707 33.853938 368.571976 368.571976 0 0 0-75.350579 49.246986 383.31916 383.31916 0 0 0-50.269601 54.360061 408.507783 408.507783 0 0 0-28.740863 41.012244A113.025869 113.025869 0 0 0 40.885614 449.667121z m0 0" fill="#ffffff" p-id="2275"></path></svg>`;
  180. if(sortDiv){
  181. var switchFilter=document.createElement("div"),enableFilter=!GM_getValue("disableFilter");
  182. var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
  183. var observer = new MutationObserver(function(records){
  184. records.map(function(record) {
  185. for(var i=0;i<record.addedNodes.length;i++){
  186. var curNode=record.addedNodes[i];
  187. if(curNode.className=="script-list"){
  188. var scripts=curNode.querySelectorAll('li');
  189. for(let i=0;i<scripts.length;i++){
  190. let script=scripts[i];
  191. addScore(script);
  192. }
  193. if(enableFilter)filter(curNode);
  194. }else if(curNode.tagName=="LI"){
  195. addScore(curNode);
  196. if(enableFilter)filter(curNode);
  197. }
  198. }
  199. });
  200. });
  201. var option = {
  202. 'childList': true
  203. };
  204. observer.observe(document.querySelector("body>.width-constraint .sidebarred-main-content"), option);
  205. var scriptList=document.querySelector("#browse-script-list,#user-script-list,ol.script-list");
  206. if(scriptList)observer.observe(scriptList, option);
  207. var scripts=document.querySelectorAll('ol.script-list>li');
  208. for(let i=0;i<scripts.length;i++){
  209. let script=scripts[i];
  210. addScore(script);
  211. }
  212. //Modify from GreasyFork Bullshit Filter,Thanks to darkred
  213. var style = document.createElement('style');
  214. style.textContent = `
  215. li.filtered {
  216. display: none !important;
  217. }
  218. .script-list>li .list-install-area{
  219. display: none;
  220. float: right;
  221. position: relative;
  222. }
  223. .script-list>li:hover .list-install-area {
  224. display: block;
  225. }
  226. @-webkit-keyframes spin {
  227. from {
  228. -webkit-transform: rotate(0deg);
  229. }
  230. to {
  231. -webkit-transform: rotate(360deg);
  232. }
  233. }
  234. @keyframes spin {
  235. from {
  236. transform: rotate(0deg);
  237. }
  238. to {
  239. transform: rotate(360deg);
  240. }
  241. }
  242. .refresh-info:hover>span {
  243. display: block;
  244. -webkit-animation: spin 1s linear 1s 5 alternate;
  245. animation: spin 1s linear infinite;
  246. }`;
  247. style.type = 'text/css';
  248. document.querySelector('head').appendChild(style);
  249. var bullshitReg=new RegExp(bullshit,"i");
  250. var filterName="Enable Filter",filteredNum=0;
  251. var filter=function(t){
  252. [].forEach.call(t.querySelectorAll('article>h2'), function(item) {
  253. if(bullshitReg.test(item.innerText.replace("\n",""))){
  254. item.parentNode.parentNode.classList.add('filtered');
  255. filteredNum++;
  256. }
  257. });
  258. };
  259. if(enableFilter)filter(document);
  260. switchFilter.innerHTML='<input type="checkBox" name="switchFilter" id="switchFilter"/><label for="switchFilter">'+filterName+(filteredNum?' ('+filteredNum+' filtered)':'')+'</label>';
  261. var switchFilterCheckbox=switchFilter.querySelector('#switchFilter');
  262. var switchFilterLabel=switchFilterCheckbox.nextSibling;
  263. switchFilterCheckbox.checked=enableFilter;
  264. switchFilterCheckbox.onclick=function(){
  265. if(enableFilter){
  266. [].forEach.call(document.querySelectorAll('li.filtered'), function(item) {
  267. item.classList.remove('filtered');
  268. });
  269. switchFilterLabel.innerHTML=filterName;
  270. }else{
  271. filteredNum=0;
  272. filter(document);
  273. switchFilterLabel.innerHTML=filterName+' ('+filteredNum+' filtered)';
  274. }
  275. GM_setValue("disableFilter",enableFilter);
  276. enableFilter=!enableFilter;
  277. };
  278. sortDiv.insertBefore(switchFilter,sortDiv.firstChild);
  279. }
  280. })();