app.porndb.me Minor Improvments

Auto show thumbnails when clicking on video

  1. // ==UserScript==
  2. // @name app.porndb.me Minor Improvments
  3. // @namespace app.porndb.me
  4. // @version 1.0
  5. // @description Auto show thumbnails when clicking on video
  6. // @author You
  7. // @match app.porndb.me
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=porndb.me
  9. // @grant none
  10. // @require http://code.jquery.com/jquery-3.4.1.min.js
  11. // @license MIT
  12. // ==/UserScript==
  13.  
  14. /* global $ */
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21. (function() {
  22. 'use strict';
  23.  
  24. //window.$ = $;
  25.  
  26. //$(".v-tabs__container").on("click", function(){
  27. // console.log("clicked");
  28. // let links = document.querySelectorAll('a');
  29.  
  30. // for (var i=links.length-1; i>=0; i--) {
  31. // links[i].setAttribute("target", "thumbnailIframe");
  32. // }
  33. //});
  34.  
  35.  
  36. // Create an observer instance linked to the callback function
  37. window.myObserver = new MutationObserver(check);
  38.  
  39. // Start observing the target node for configured mutations
  40. window.myObserver.observe(document, {childList: true, subtree: true});
  41.  
  42. //(new MutationObserver(check)).observe(document, {childList: true, subtree: true});
  43.  
  44. function check(changes, observer) {
  45. if(document.querySelector('.v-content__wrap .flex.lg4.md4.pa-2.sm6.xl4.xs12')) {
  46. //observer.disconnect();
  47. // code
  48.  
  49. $(".v-content__wrap .flex.lg4.md4.pa-2.sm6.xl4.xs12").off();
  50.  
  51. $(".v-content__wrap .flex.lg4.md4.pa-2.sm6.xl4.xs12").on("click", function(){
  52. //alert("click");
  53. //setTimeout(() => {
  54. // $("#thumbnailIframe").remove();
  55. // $('<iframe id="thumbnailIframe" name="thumbnailIframe" src="target.html" style="background:#ffffff; width:100%;"></iframe>').insertAfter($(".v-dialog--active .v-tabs__bar"))
  56. //}, 2000);
  57.  
  58. //document.querySelector(".v-dialog--active .v-tabs__bar").insertAdjacentHTML("afterend", '<iframe id="thumbnailIframe" name="thumbnailIframe" src="target.html" style="background:#ffffff; width:100%;"></iframe>');
  59. });
  60. }
  61.  
  62. if(document.querySelector('.v-dialog--active') && $(".v-dialog--active #thumbnailIframe").length == 0) {
  63. //observer.disconnect();
  64. //alert("Prompt Open");
  65. setTimeout(() => {
  66. $("#thumbnailIframe").remove();
  67. //$('<iframe id="thumbnailIframe" name="thumbnailIframe" src="target.html" style="background:#ffffff; width:100%;"></iframe>').insertAfter($(".v-dialog--active .v-tabs__bar"));
  68. //$('<img id="thumbnailIframe" name="thumbnailIframe" src="target.html" style="background:#ffffff; width:100%;"></img>').insertAfter($(".v-dialog--active .v-tabs__bar"));
  69. //$('<img id="thumbnailIframe" name="thumbnailIframe" src="target.html" style="background:#ffffff; width:100%;"></img>').prepend($(".v-dialog--active [role='list']")[0]);
  70. $($(".v-dialog--active [role='list']")[0]).prepend($('<img id="thumbnailIframe" name="thumbnailIframe" src="target.html" style="background:#ffffff; width:100%; display:none;"></img>'));
  71. }, 200);
  72. }
  73.  
  74. if(document.querySelector('.v-dialog--active')){
  75. console.log("clicked");
  76. let regex = new RegExp('\.(jpg|png)$');
  77. //let links = document.querySelectorAll('a');
  78.  
  79. //for (var i=links.length-1; i>=0; i--) {
  80. // links[i].setAttribute("target", "thumbnailIframe");
  81. //}
  82.  
  83.  
  84.  
  85. for(let i=0; i<$(".v-dialog--active .pa-2").length; i++){
  86. console.log($(".v-dialog--active .pa-2")[i]);
  87. console.log(regex.test($(".v-dialog--active .pa-2")[i]))
  88. if(regex.test($(".v-dialog--active .pa-2")[i]) == true){
  89. // Use this URL as Thumbnail URL
  90. console.log("setting thumbnail");
  91. $("#thumbnailIframe").attr("src", $(".v-dialog--active .pa-2")[i])
  92. $("#thumbnailIframe").show();
  93. }
  94. }
  95.  
  96. }
  97. }
  98.  
  99. //(new MutationObserver(checkPromptOpen)).observe(document, {childList: true, subtree: true});
  100.  
  101. //function checkPromptOpen(changes, observer) {
  102.  
  103. //}
  104.  
  105.  
  106.  
  107. //$(".v-content__wrap .flex.lg4.md4.pa-2.sm6.xl4.xs12").on("click", function(){
  108. // alert("click");
  109. //});
  110.  
  111. //.v-content__wrap .flex.lg4.md4.pa-2.sm6.xl4.xs12
  112. })();