HTML5 player for BBC News

Use a natively uncluttered hardware-accelerated player, no ads or annoyances. Also, easily downloadable videos.

2015-07-16 या दिनांकाला. सर्वात नवीन आवृत्ती पाहा.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

You will need to install an extension such as Tampermonkey to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name        HTML5 player for BBC News
// @match       http://www.bbc.com/*
// @version     2015.07.16
// @description Use a natively uncluttered hardware-accelerated player, no ads or annoyances. Also, easily downloadable videos.
// @grant       GM_xmlhttpRequest
// @namespace   https://greasyfork.org/users/4813
// ==/UserScript==


for (var i in (src = document.querySelectorAll('script:not([src])')))
{
    if (typeof src[i] !== 'object' || src[i].textContent.indexOf('externalId') === -1)
    {
        continue;
    }

    var vpid = src[i].textContent.match(/externalId":"([^"]+)"/)[1];

    console.log(i, vpid);
}

if (!vpid)
  throw 'BBC HTML5: nothing to do :)';

  GM_xmlhttpRequest(
  {
    method: 'GET',
    url: 'http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/vpid/' + vpid + '/format/json/mediaset/journalism-http-tablet/',

    onreadystatechange: function(e)
    {
      if (e.readyState !== XMLHttpRequest.DONE)
      {
        return;
      }

      this.responseJSON = JSON.parse(e.responseText);

      /* just for taking a look, please don't mind me! :-) */
      console.log(e, this.responseJSON);

      unsafeWindow.cock = e.responseText;//this.responseJSON;

      if (!this.responseJSON.media)
      {
        console.warn('BBC HTML5: the listing did not come with any video at all!', this.responseJSON); return;
      }

      /* add a download button per result video */
      for(var vid in this.responseJSON.media)
      {
        //console.log("=>", vid, this.responseJSON.media, this.responseJSON.media[vid], this.responseJSON.media[vid].connection[0].href);

        console.log("=>", vid, this.responseJSON.media[vid].width,
                               this.responseJSON.media[vid].height,
                               this.responseJSON.media[vid],
                               this.responseJSON.media[vid].connection[0].href);

      /*
        dwnbutton = document.createElement("a");
        dwnbutton.setAttribute('style', 'padding-left: 35px; padding-right:12px');

        dwnbutton.textContent = 'Descargar [' + vid + ']';
        dwnbutton.className   = 'mar-l_10 fn_slide_link left btn_black icon_35 descarga';
        dwnbutton.href        = this.responseJSON.media[vid];
        dwnbutton.download    = document.querySelector('#imagen_modulo_player > img').alt + '.' + vid + '.mp4';

        / / * replace it on the page * / /
        dwnbuttonHolderElement = document.querySelector('.mod_producto_social > div > div');
        dwnbuttonHolderElement.appendChild(dwnbutton); */
      }

      var hq = 2 // 0;

      /* build our own html5 player with our own stuff */
      vplayer = document.createElement('video');

      vplayer.src      = this.responseJSON.media[hq].connection[0].href;
      vplayer.poster   = document.querySelector('#media-asset-placeholder').src;

      vplayer.controls = 'true';
      vplayer.autoplay = 'false';
      vplayer.preload  = 'none';

      vplayer.volume   = '0.4';

      vplayer.style.width = '100%';

      /* replace it on the page */
      videoHolderElement = document.querySelector('#media-asset-page-video');
      videoHolderElement.parentElement.replaceChild(vplayer, videoHolderElement);
    },

    onerror: function(e)
    {
      console.warn('BBC HTML5: Houston, we have an unidentified problem!', e);
    }
  });