Greasyfork Search with Sleazyfork Results include

Merge adult results of sleazyfork into greasyfork when the script is no longer anonymously available, add rating score and version for scripts then

  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 1.6.6
  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. // @match http*://greatest.deepsurf.us/*
  14. // @match http*://www.greatest.deepsurf.us/*
  15. // @match http*://sleazyfork.org/*
  16. // @match http*://www.sleazyfork.org/*
  17. // @grant GM_xmlhttpRequest
  18. // @grant GM_setValue
  19. // @grant GM_getValue
  20. // @grant GM_registerMenuCommand
  21. // @grant GM_notification
  22. // @grant GM.xmlHttpRequest
  23. // @grant GM.setValue
  24. // @grant GM.getValue
  25. // @grant GM.registerMenuCommand
  26. // @grant GM.notification
  27. // @connect greatest.deepsurf.us
  28. // @connect sleazyfork.org
  29. // @contributionURL https://www.buymeacoffee.com/hoothin
  30. // @contributionAmount 1
  31. // ==/UserScript==
  32.  
  33. (function() {
  34. 'use strict';
  35. var _GM_xmlhttpRequest,_GM_registerMenuCommand,_GM_notification;
  36. if(typeof GM_xmlhttpRequest!='undefined'){
  37. _GM_xmlhttpRequest=GM_xmlhttpRequest;
  38. }else if(typeof GM!='undefined' && typeof GM.xmlHttpRequest!='undefined'){
  39. _GM_xmlhttpRequest=GM.xmlHttpRequest;
  40. }
  41. if(typeof GM_registerMenuCommand!='undefined'){
  42. _GM_registerMenuCommand=GM_registerMenuCommand;
  43. }else if(typeof GM!='undefined' && typeof GM.registerMenuCommand!='undefined'){
  44. _GM_registerMenuCommand=GM.registerMenuCommand;
  45. }
  46. if(typeof GM_notification!='undefined'){
  47. _GM_notification=GM_notification;
  48. }else if(typeof GM!='undefined' && typeof GM.notification!='undefined'){
  49. _GM_notification=GM.notification;
  50. }
  51.  
  52. if(typeof _GM_xmlhttpRequest=='undefined')_GM_xmlhttpRequest=(f)=>{};
  53. if(typeof _GM_registerMenuCommand=='undefined')_GM_registerMenuCommand=(s,f)=>{};
  54. if(typeof _GM_notification=='undefined')_GM_notification=(s)=>{};
  55. var storage={
  56. supportGM: typeof GM_getValue=='function' && typeof GM_getValue('a','b')!='undefined',
  57. supportGMPromise: typeof GM!='undefined' && typeof GM.getValue=='function' && typeof GM.getValue('a','b')!='undefined',
  58. mxAppStorage:(function(){
  59. try{
  60. return window.external.mxGetRuntime().storage;
  61. }catch(e){
  62. };
  63. })(),
  64. operaUJSStorage:(function(){
  65. try{
  66. return window.opera.scriptStorage;
  67. }catch(e){
  68. };
  69. })(),
  70. setItem:function(key,value){
  71. if(this.operaUJSStorage){
  72. this.operaUJSStorage.setItem(key,value);
  73. }else if(this.mxAppStorage){
  74. this.mxAppStorage.setConfig(key,value);
  75. }else if(this.supportGM){
  76. GM_setValue(key,value);
  77. }else if(this.supportGMPromise){
  78. GM.setValue(key,value);
  79. }else if(window.localStorage){
  80. window.localStorage.setItem(key,value);
  81. };
  82. },
  83. getItem:function(key,cb){
  84. var value;
  85. if(this.operaUJSStorage){
  86. value=this.operaUJSStorage.getItem(key);
  87. }else if(this.mxAppStorage){
  88. value=this.mxAppStorage.getConfig(key);
  89. }else if(this.supportGM){
  90. value=GM_getValue(key);
  91. }else if(this.supportGMPromise){
  92. value=GM.getValue(key).then(v=>{cb(v)});
  93. return;
  94. }else if(window.localStorage){
  95. value=window.localStorage.getItem(key);
  96. };
  97. cb(value);
  98. },
  99. };
  100. if(document.querySelector('span.sign-in-link')){
  101. var otherSite=/greasyfork\.org/.test(location.hostname)?"sleazyfork":"greasyfork";
  102. if(/scripts\/\d+/.test(location.href)){
  103. if(!document.querySelector("#script-info") && (otherSite == "greasyfork" || document.querySelector("div.width-constraint>section>p>a").href.indexOf("sign_in")!=-1)){
  104. location.href=location.href.replace(/\/\/([^\.]+\.)?(greasyfork|sleazyfork)\.org/,"//$1"+otherSite+"\.org");
  105. }
  106. }else if(/\/(scripts|users)(\/|.*(\?|&)q=|.*[\?&]set=)/.test(location.href)){
  107. _GM_xmlhttpRequest({
  108. method: 'GET',
  109. url: location.href.replace(/\/\/([^\.]+\.)?(greasyfork|sleazyfork)\.org/,"//$1"+otherSite+"\.org"),
  110. onload: function(result) {
  111. var doc = null;
  112. try {
  113. doc = document.implementation.createHTMLDocument('');
  114. doc.documentElement.innerHTML = result.responseText;
  115. }
  116. catch (e) {
  117. console.log('parse error');
  118. }
  119. if (!doc) {
  120. return;
  121. }
  122. var l = doc.querySelector('ol.script-list');
  123. if (l) {
  124. var ml = document.querySelector('ol.script-list');
  125. if(!ml){
  126. ml=document.createElement("ol");
  127. ml.setAttribute("class","script-list");
  128. var list=document.querySelector('.sidebarred-main-content');
  129. var ps=list.querySelectorAll("p");
  130. for(let i=0;i<ps.length;i++){
  131. let p=ps[i];
  132. list.removeChild(p);
  133. }
  134. list.appendChild(ml);
  135. }
  136. var scs=l.querySelectorAll("li");
  137. if(scs){
  138. for(let i=0;i<scs.length;i++){
  139. let sc=scs[i];
  140. if(!ml.querySelector("li[data-script-id='"+sc.dataset.scriptId+"']")){
  141. //addScore(sc);
  142. ml.appendChild(sc);
  143. }
  144. }
  145. }
  146. }
  147. },
  148. onerror: function(e) {
  149. console.log(e);
  150. }
  151. });
  152. }
  153. }
  154.  
  155. var bullshit,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`;
  156. var sortDiv=document.querySelector("#script-list-sort"),refreshIcon=document.createElement("span"),inUserPage=document.querySelector("#user-script-list")!=null,goodRating,okRating,badRating,totalInstalls,dailyInstalls;
  157. 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>`;
  158. if(inUserPage){
  159. var ratingSpan=document.createElement("span");
  160. goodRating=document.createElement("span");
  161. okRating=document.createElement("span");
  162. badRating=document.createElement("span");
  163. totalInstalls=document.createElement("span");
  164. dailyInstalls=document.createElement("span");
  165. goodRating.className="good-rating-count";
  166. okRating.className="ok-rating-count";
  167. badRating.className="bad-rating-count";
  168. totalInstalls.className="good-rating-count";
  169. dailyInstalls.className="good-rating-count";
  170. ratingSpan.appendChild(goodRating);
  171. ratingSpan.appendChild(okRating);
  172. ratingSpan.appendChild(badRating);
  173. document.querySelector("#script-list-sort ul>li:nth-child(1)").appendChild(dailyInstalls);
  174. document.querySelector("#script-list-sort ul>li:nth-child(2)").appendChild(totalInstalls);
  175. document.querySelector("#script-list-sort ul>li:nth-child(3)").appendChild(ratingSpan);
  176. ratingSpan.style.display=totalInstalls.style.display=dailyInstalls.style.display="none";
  177. goodRating.innerHTML=okRating.innerHTML=badRating.innerHTML=totalInstalls.innerHTML=dailyInstalls.innerHTML="0";
  178. }
  179. storage.getItem("GeasyforkBullshit",v=>{
  180. bullshit=v;
  181. if(!bullshit)bullshit=bullshit_o;
  182. if(/greasyfork\.org\/.*\/scripts\/23840[^\/]*$/.test(location.href)){
  183. var p=document.createElement("p"),_bullshit;
  184. p.style.width="99%";
  185. p.innerHTML="<b>Filter RegExp</b><button id='ok' style='margin-left: 20px;'>Save</button><button id='reset' style='margin-left: 20px;'>Reset</button>";
  186. var okBtn=p.querySelector("#ok");
  187. var resetBtn=p.querySelector("#reset");
  188. var filterTextarea=document.createElement("pre");
  189. var prettifyScript=document.createElement("script");
  190. prettifyScript.src="https://cdnjs.cloudflare.com/ajax/libs/prettify/r298/prettify.min.js?skin=sons-of-obsidian";
  191. document.head.appendChild(prettifyScript);
  192. var prettifyStyle=document.createElement("link");
  193. prettifyStyle.rel="stylesheet";
  194. prettifyStyle.href="https://cdnjs.cloudflare.com/ajax/libs/prettify/r298/prettify.min.css";
  195. document.head.appendChild(prettifyStyle);
  196. filterTextarea.contentEditable="true";
  197. filterTextarea.className="prettyprint lang-js";
  198. filterTextarea.style.whiteSpace="pre-wrap";
  199. filterTextarea.style.overflowWrap="break-word";
  200. filterTextarea.style.width="100%";
  201. filterTextarea.innerHTML=bullshit;
  202. var additionalInfo=document.querySelector("#additional-info");
  203. p.appendChild(filterTextarea);
  204. additionalInfo.insertBefore(p,additionalInfo.firstChild);
  205. prettifyScript.onload=()=>{PR.prettyPrint();};
  206. okBtn.onclick=()=>{
  207. _bullshit=filterTextarea.innerText;
  208. storage.setItem("GeasyforkBullshit", _bullshit);
  209. alert("Saved");
  210. //_GM_notification("Saved");
  211. };
  212. resetBtn.onclick=()=>{
  213. storage.setItem("GeasyforkBullshit", bullshit_o);
  214. alert("Reset over");
  215. location.reload();
  216. //_GM_notification("Reset over");
  217. };
  218. }
  219. initFilter();
  220. });
  221.  
  222. function addScore(script){
  223. var separator=script.querySelector('h2>span.name-description-separator');
  224. var description=script.querySelector('h2>span.description');
  225. if(separator){
  226. var score=document.createElement("strong");
  227. score.style.color="#e09015";
  228. score.innerHTML=script.dataset.scriptRatingScore;
  229. separator.parentNode.insertBefore(score,separator);
  230. }
  231. if(description){
  232. count(script);
  233. var scriptHref=script.querySelector('h2>a').href;
  234. let version=script.dataset.scriptVersion;
  235. let format=script.dataset.scriptLanguage;
  236. let cssAtag=script.dataset.scriptLanguage=="js"?"":`<a class="install-link" data-install-format="css" data-ping-url href="${scriptHref.replace(/\.org\/.*\/scripts\//,".org/scripts/")}/code/script.user.css">Install as user style</a>`;
  237. description.innerHTML+=`<strong>Ver.${version}</strong>
  238. <div id="install-area" class="list-install-area">
  239. <a class="install-link" data-install-format="js" 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>
  240. ${cssAtag}
  241. </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>`;
  242. var installArea=description.querySelector("#install-area");
  243. let installLink=installArea.querySelector(".install-link");
  244. let checkInfo=installArea.querySelector(".install-help-link");
  245. script.onmouseenter=e=>{
  246. checkInfo.appendChild(refreshIcon);
  247. };
  248. script.onmouseleave=e=>{
  249. if(refreshIcon && refreshIcon.parentNode)refreshIcon.parentNode.removeChild(refreshIcon);
  250. };
  251. checkInfo.onclick=()=>{
  252. _GM_xmlhttpRequest({
  253. method: 'GET',
  254. url: scriptHref.replace(/(.*)-.*/,"$1.json"),
  255. onload: function(result) {
  256. var data = null;
  257. try {
  258. data = JSON.parse(result.responseText);
  259. }
  260. catch (e) {
  261. console.log('parse error');
  262. }
  263. if(data){
  264. let setInfo=info=>{
  265. if(info.installed){
  266. if(parseFloat(info.version) < parseFloat(version)){
  267. installLink.innerHTML="Update to version "+version;
  268. }else if(parseFloat(info.version) > parseFloat(version)){
  269. installLink.innerHTML="Downgrade to version "+version;
  270. }else{
  271. installLink.innerHTML="Reinstall version "+version;
  272. }
  273.  
  274. if(!info.enabled){
  275. installLink.style.backgroundColor="#6a6a6a";
  276. }else{
  277. installLink.style.backgroundColor="";
  278. }
  279. }else{
  280. installLink.innerHTML="Install version "+version;
  281. }
  282. };
  283. if(window.external.Tampermonkey){
  284. window.external.Tampermonkey.isInstalled(data.name, data.namespace, e=>{
  285. setInfo(e);
  286. });
  287. }else if(window.external.Violentmonkey){
  288. window.external.Violentmonkey.isInstalled(data.name, data.namespace).then(e=>{
  289. setInfo(e);
  290. });
  291. }
  292. }
  293. }
  294. });
  295. };
  296. if(!window.external.Tampermonkey && !window.external.Violentmonkey){
  297. checkInfo.style.display="none";
  298. }
  299. }
  300. }
  301.  
  302. function count(script){
  303. var dailySpan=script.querySelector("dd.script-list-daily-installs>span");
  304. if(!dailySpan)return;
  305. var goodCount=parseInt(script.querySelector("dd.script-list-ratings>span>.good-rating-count").innerHTML.replace(/[^\d]/g,""));
  306. var okCount=parseInt(script.querySelector("dd.script-list-ratings>span>.ok-rating-count").innerHTML.replace(/[^\d]/g,""));
  307. var badCount=parseInt(script.querySelector("dd.script-list-ratings>span>.bad-rating-count").innerHTML.replace(/[^\d]/g,""));
  308. if(badCount && badCount>2 && badCount>goodCount){
  309. let scriptLink=script.querySelector('.script-link');
  310. if(scriptLink){
  311. var warn=document.createTextNode("⚠");
  312. scriptLink.style.textDecoration="line-through";
  313. scriptLink.style.color="#67000080";
  314. scriptLink.title="May be dangerous!";
  315. scriptLink.parentNode.insertBefore(warn,scriptLink);
  316. }
  317. }
  318.  
  319. if(!inUserPage)return;
  320. var dailyCount=parseInt(dailySpan.innerHTML.replace(/[^\d\.\-]/g,""));
  321. var totalCount=parseInt(script.querySelector("dd.script-list-total-installs>span").innerHTML.replace(/[^\d]/g,""));
  322. goodRating.innerHTML=parseInt(goodRating.innerHTML)+goodCount;
  323. okRating.innerHTML=parseInt(okRating.innerHTML)+okCount;
  324. badRating.innerHTML=parseInt(badRating.innerHTML)+badCount;
  325. totalInstalls.innerHTML=parseInt(totalInstalls.innerHTML)+totalCount;
  326. dailyInstalls.innerHTML=parseInt(dailyInstalls.innerHTML)+dailyCount;
  327. ratingSpan.style.display=totalInstalls.style.display=dailyInstalls.style.display="";
  328. }
  329.  
  330. _GM_registerMenuCommand("Configure the Filter", ()=>{
  331. location.href="https://greatest.deepsurf.us/scripts/23840#additional-info";
  332. /*var _bullshit=window.prompt("Configure the Filter", bullshit);
  333. if(_bullshit == ""){
  334. bullshit=bullshit_o;
  335. storage.setItem("GeasyforkBullshit", bullshit);
  336. location.reload();
  337. }else if(_bullshit != null){
  338. bullshit=_bullshit;
  339. storage.setItem("GeasyforkBullshit", bullshit);
  340. location.reload();
  341. }*/
  342. });
  343.  
  344. function initFilter(){
  345. var enableFilter;
  346. if(sortDiv){
  347. storage.getItem("disableFilter",v=>{
  348. enableFilter=!v;
  349. var switchFilter=document.createElement("div");
  350. var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
  351. var observer = new MutationObserver(function(records){
  352. records.map(function(record) {
  353. for(var i=0;i<record.addedNodes.length;i++){
  354. var curNode=record.addedNodes[i];
  355. if(curNode.className=="script-list"){
  356. var scripts=curNode.querySelectorAll('li');
  357. for(let i=0;i<scripts.length;i++){
  358. let script=scripts[i];
  359. addScore(script);
  360. }
  361. if(enableFilter)filter(curNode);
  362. }else if(curNode.tagName=="LI"){
  363. addScore(curNode);
  364. if(enableFilter)filter(curNode);
  365. }
  366. }
  367. });
  368. });
  369. var option = {
  370. 'childList': true
  371. };
  372. observer.observe(document.querySelector("body>.width-constraint .sidebarred-main-content"), option);
  373. var scriptList=document.querySelector("#browse-script-list,#user-script-list,ol.script-list");
  374. if(scriptList)observer.observe(scriptList, option);
  375. var scripts=document.querySelectorAll('ol.script-list>li');
  376. for(let i=0;i<scripts.length;i++){
  377. let script=scripts[i];
  378. addScore(script);
  379. }
  380. //Modify from GreasyFork Bullshit Filter,Thanks to darkred
  381. var style = document.createElement('style');
  382. style.textContent = `
  383. li.filtered {
  384. display: none !important;
  385. }
  386. .list-option{
  387. position: relative;
  388. }
  389. #script-list-sort li>span{
  390. position: absolute;
  391. top: 4px;
  392. right: 2px;
  393. pointer-events: none;
  394. font-weight: 500;
  395. }
  396. #script-list-sort li>span:lang(ar), #script-list-sort li>span:lang(he), #script-list-sort li>span:lang(ug){
  397. right: unset;
  398. left: 2px;
  399. }
  400. #script-list-sort li>span>span{
  401. margin: 0 0 0 2px;
  402. }
  403. .script-list>li .list-install-area{
  404. display: none;
  405. float: right;
  406. position: relative;
  407. }
  408. .script-list>li:hover .list-install-area {
  409. display: block;
  410. }
  411. @-webkit-keyframes spin {
  412. from {
  413. -webkit-transform: rotate(0deg);
  414. }
  415. to {
  416. -webkit-transform: rotate(360deg);
  417. }
  418. }
  419. @keyframes spin {
  420. from {
  421. transform: rotate(0deg);
  422. }
  423. to {
  424. transform: rotate(360deg);
  425. }
  426. }
  427. .refresh-info:hover>span {
  428. display: block;
  429. -webkit-animation: spin 1s linear 1s 5 alternate;
  430. animation: spin 1s linear infinite;
  431. }`;
  432. style.type = 'text/css';
  433. document.querySelector('head').appendChild(style);
  434. var bullshitReg=new RegExp(bullshit,"i");
  435. var filterName="Enable Filter",filteredNum=0;
  436. var filter=function(t){
  437. [].forEach.call(t.querySelectorAll('article>h2'), function(item) {
  438. if(bullshitReg.test(item.innerText.replace("\n"," "))){
  439. item.parentNode.parentNode.classList.add('filtered');
  440. filteredNum++;
  441. }
  442. });
  443. };
  444. if(enableFilter)filter(document);
  445. switchFilter.innerHTML='<input type="checkBox" name="switchFilter" id="switchFilter"/><label for="switchFilter">'+filterName+(filteredNum?' ('+filteredNum+' filtered)':'')+'</label>';
  446. var switchFilterCheckbox=switchFilter.querySelector('#switchFilter');
  447. var switchFilterLabel=switchFilterCheckbox.nextSibling;
  448. switchFilterCheckbox.checked=enableFilter;
  449. switchFilterCheckbox.onclick=function(){
  450. if(enableFilter){
  451. [].forEach.call(document.querySelectorAll('li.filtered'), function(item) {
  452. item.classList.remove('filtered');
  453. });
  454. switchFilterLabel.innerHTML=filterName;
  455. }else{
  456. filteredNum=0;
  457. filter(document);
  458. switchFilterLabel.innerHTML=filterName+' ('+filteredNum+' filtered)';
  459. }
  460. storage.setItem("disableFilter",enableFilter);
  461. enableFilter=!enableFilter;
  462. };
  463. sortDiv.insertBefore(switchFilter,sortDiv.firstChild);
  464. });
  465. }
  466. }
  467. })();