91porn_display_m3u8_address

91porn show m3u8 address

  1. // ==UserScript==
  2. // @name 91porn_display_m3u8_address
  3. // @name:zh-CN 91porn_display_m3u8_address
  4. // @namespace:zh-TW 91porn_display_m3u8_address
  5. // @supportURL https://github.com/zhuzemin
  6. // @description 91porn show m3u8 address
  7. // @description:zh-CN 91porn show m3u8 address
  8. // @description:zh-TW 91porn show m3u8 address
  9. // @include http://www.91porn.com/view_video.php?viewkey=*
  10. // @version 1.0
  11. // @run-at document-end
  12. // @author zhuzemin
  13. // @license Mozilla Public License 2.0; http://www.mozilla.org/MPL/2.0/
  14. // @license CC Attribution-ShareAlike 4.0 International; http://creativecommons.org/licenses/by-sa/4.0/
  15. // @grant GM_registerMenuCommand
  16. // @grant GM_setValue
  17. // @grant GM_getValue
  18. // @namespace https://greasyfork.org/users/400918
  19. // ==/UserScript==
  20. let config = {
  21. 'debug': false,
  22. 'version': GM_getValue('version') || '2.9.7'
  23. };
  24. let debug = config.debug ? console.log.bind(console) : function () {
  25. };
  26. // prepare UserPrefs
  27. setUserPref(
  28. 'version',
  29. config.version,
  30. 'Set N_m3u8DL version',
  31. `Set N_m3u8DL version`,
  32. );
  33. let init = function () {
  34. if (window.self === window.top) {
  35. let input = document.createElement("input");
  36. input.setAttribute("type", "text");
  37. input.size = window.screen.width;
  38. document.body.insertBefore(input, document.body.firstChild);
  39. let N_m3u8DL = document.createElement("input");
  40. N_m3u8DL.setAttribute("type", "text");
  41. N_m3u8DL.size = window.screen.width;
  42. document.body.insertBefore(N_m3u8DL, document.body.firstChild);
  43. let title = document.title.replace(' Chinese homemade video', '');
  44. let interval = setInterval(() => {
  45. let video = document.querySelector('video');
  46. if (video) {
  47. clearInterval(interval);
  48. let source = video.querySelector('source');
  49. let url = source.src;
  50. debug(url);
  51. N_m3u8DL.setAttribute("value", 'N_m3u8DL-CLI_v' + config.version + ' "' + url + '" --headers "Referer:' + window.location.href + '" --saveName "' + title + '"');
  52. input.setAttribute("value", url);
  53. }
  54. }, 1000);
  55. }
  56. }
  57. window.addEventListener('DOMContentLoaded', init);
  58. /**
  59. * Create a user setting prompt
  60. * @param {string} varName
  61. * @param {any} defaultVal
  62. * @param {string} menuText
  63. * @param {string} promtText
  64. * @param {function} func
  65. */
  66. function setUserPref(varName, defaultVal, menuText, promtText, func = null) {
  67. GM_registerMenuCommand(menuText, function () {
  68. var val = prompt(promtText, GM_getValue(varName, defaultVal));
  69. if (val === null) { return; } // end execution if clicked CANCEL
  70. GM_setValue(varName, val);
  71. if (func != null) {
  72. func(val);
  73. }
  74. });
  75. }
  76. function getLocation(href) {
  77. let l = document.createElement("a");
  78. l.href = href;
  79. return l;
  80. };