Sleazy Fork is available in English.

Get_Dcard_Sex_Resource

取得Dcard所有評論裡需要密碼的影片、圖片連結

  1. // ==UserScript==
  2. // @name Get_Dcard_Sex_Resource
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description 取得Dcard所有評論裡需要密碼的影片、圖片連結
  6. // @author You
  7. // @include https://www.dcard.tw/f/sex*
  8. // @require https://greasyfork.org/scripts/5392-waitforkeyelements/code/WaitForKeyElements.js?version=115012
  9. //@run-at document-end
  10. //@require https://code.jquery.com/jquery-3.3.1.min.js
  11. // @grant none
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17.  
  18. //waitForKeyElements ("[class^=RegulationModal_container]", RemoveValidateAgeDiv);
  19. waitForKeyElements ("[class^=PostPage_content]", Main);
  20.  
  21. })();
  22.  
  23.  
  24. function RemoveValidateAgeDiv(){
  25. console.log("remove dev");
  26. $("[class^=RegulationModal_container]").closest('[class^=Modal_modal]').remove();
  27. $('html, body').css('overflowY', 'auto');
  28. }
  29.  
  30. //程式主要進入點
  31. function Main(){
  32. var postId = GetPostIdbyUrl();
  33. var sexResourceUrls = FindResourceInMainContent(postId);
  34. sexResourceUrls = sexResourceUrls.concat(FindResourceInComment());
  35. console.log("All match urls:"+sexResourceUrls.join(','));
  36.  
  37. }
  38.  
  39. function GetPostIdbyUrl(){
  40. var url = window.location.href;
  41. var postId = 0;
  42. //取得文章編號
  43. var MatchPostId = /https:\/\/www\.dcard\.tw\/f\/(\w+)\/p\/(\d+).*/g;
  44. var Match = MatchPostId.exec(url);
  45. if(Match)
  46. postId = Match[2];
  47. return postId;
  48. }
  49.  
  50. function FindResourceInComment(postId){
  51. var sexResourceUrls = [];
  52.  
  53. //取得所有評論
  54. $.getJSON('https://www.dcard.tw/_api/posts/'+postId+'/comments', function(comments) {
  55. comments.forEach(function(comment, index) {
  56.  
  57. if(comment.anonymous && comment.gender == "F"){
  58. var content = comment.content;
  59. console.log(comment.content);
  60. sexResourceUrls = sexResourceUrls.concat(MatchUrlInContent(content));
  61. }
  62.  
  63. });//end of data foreach
  64. });//end of getJSON
  65.  
  66. return sexResourceUrls;
  67. }
  68.  
  69. function FindResourceInMainContent(){
  70. var content = $("[class^=Post_content]").html();
  71. return MatchUrlInContent(content);
  72. }
  73.  
  74. function MatchUrlInContent(content){
  75. var Urls = [];
  76. var MatchVimeo = /https:\/\/player\.vimeo\.com\/video\/\d+/gm;
  77. var matches;
  78. console.log(content);
  79. while (matches = MatchVimeo.exec(content)) {
  80. console.log(matches);
  81. Urls.push(matches[1]);
  82. }
  83.  
  84. var MatchPpt = /https:\/\/ppt\.cc\/\w+/gm;
  85. while (matches = MatchPpt.exec(content)) {
  86. console.log(matches);
  87. Urls.push(matches[1]);
  88. }
  89.  
  90. return Urls;
  91. }