Greasy Fork is available in English.

La7.tv direct link

This script gives you the direct link while watching a video on La7.it

  1. // ==UserScript==
  2. // @name La7.tv direct link
  3. // @name:it La7.it - Link diretti
  4. // @namespace http://andrealazzarotto.com/
  5. // @version 3.1.0
  6. // @description This script gives you the direct link while watching a video on La7.it
  7. // @description:it Ottieni il link diretto ai video su La7.it
  8. // @author Andrea Lazzarotto
  9. // @match https://la7.it/*
  10. // @match https://*.la7.it/*
  11. // @require https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.1/jquery.min.js
  12. // @grant GM_xmlhttpRequest
  13. // @grant GM.xmlHttpRequest
  14. // @grant unsafeWindow
  15. // @connect kdam.iltrovatore.it
  16. // @license GPL version 3 or any later version; http://www.gnu.org/copyleft/gpl.html
  17. // ==/UserScript==
  18.  
  19. /* Greasemonkey 4 wrapper */
  20. if (typeof GM !== "undefined" && !!GM.xmlHttpRequest)
  21. GM_xmlhttpRequest = GM.xmlHttpRequest;
  22.  
  23. var appendURL = function(element, url, entry_id) {
  24. var identifier = 'direct-link-' + entry_id;
  25. if ($('#' + identifier).length)
  26. return;
  27. element.after('<div id="' + identifier + '"></div>');
  28. $('#' + identifier).css({
  29. 'padding': '5px 0',
  30. 'margin': '15px auto',
  31. 'width': '20rem',
  32. 'max-width': '90%',
  33. 'border': '1px solid #888',
  34. 'text-align': 'center',
  35. 'background-color': '#cfc',
  36. 'box-shadow': '0px 5px 15px 0px rgba(0, 0, 0, .7)',
  37. 'font-family': 'sans-serif'
  38. }).append("<a href='" + url + "'>MP4 Direct Link</a>");
  39. $("#direct-link-" + entry_id + " a")
  40. .css('color', 'black')
  41. .css('text-decoration', 'none')
  42. .css('font-size', '15px');
  43. };
  44.  
  45. var handleObject = function(obj) {
  46. var content = obj.text();
  47. var entry_id = content.split('entry_id')[1].split('/')[1];
  48.  
  49. // Prevent double matches
  50. if (content.indexOf("@context") > 0) {
  51. return;
  52. }
  53.  
  54. // Use super-easy iOS URL when available
  55. console.log(content);
  56. console.log(unsafeWindow.iosUrl);
  57. if (content.indexOf('window.iosUrl') > 0 && unsafeWindow.iosUrl && unsafeWindow.iosUrl.indexOf('.mp4') > 0) {
  58. appendURL(obj.parent(), unsafeWindow.iosUrl, entry_id);
  59. }
  60.  
  61. var hints = [];
  62. if (content.indexOf('"m3u8"') > 0) {
  63. hints = content.split('"m3u8"')[1].split('http')[1].split('"')[0].split(',').slice(1,-1);
  64. }
  65.  
  66. // Thanks to: https://web.archive.org/web/20140330171953/http://www.leoiannacone.com/2014/03/il-caso-la7-it-e-la-questione-del-nuovo-player/
  67. var data_url = 'http://kdam.iltrovatore.it/p/103/sp/10300/playManifest/entryId/' + entry_id;
  68. console.log(data_url);
  69. GM_xmlhttpRequest({
  70. method: 'GET',
  71. url: data_url,
  72. headers: {
  73. 'Accept': 'application/atom+xml,application/xml,text/xml'
  74. },
  75. onload: function(responseDetails) {
  76. var r = responseDetails.responseText;
  77. var doc = $.parseXML(r);
  78. var $xml = $(doc);
  79.  
  80. var media_url = $xml.find("media").attr('url');
  81. if (!media_url) {
  82. // Skip DRM protected content
  83. return;
  84. }
  85. if (hints.length > 1) {
  86. media_url = media_url.replace(hints[0], hints[hints.length-1]);
  87. }
  88. appendURL(obj.parent(), media_url, entry_id);
  89. }
  90. });
  91. };
  92.  
  93. $(document).ready(function(){
  94. var objects = $('script:contains("entry_id")');
  95. objects.each(function() {
  96. handleObject($(this));
  97. });
  98. });