Widget:BilibiliVideo:修订间差异

H萌娘,万物皆可H的百科全书!
跳到导航 跳到搜索
imported>=海豚=
无编辑摘要
imported>=海豚=
无编辑摘要
第16行: 第16行:
}
}
.bilibili-video-container,
.bilibili-video-container,
.bilibili-video-container div,
.bilibili-video-container .bilibili-widescreen,
.bilibili-video-container .bilibili-widescreen,
.bilibili-video-container iframe {
.bilibili-video-container iframe {
第77行: 第76行:
    border: 0 solid rgba(170,170,170,0.37);
    border: 0 solid rgba(170,170,170,0.37);
    border-top-width: 1px;
    border-top-width: 1px;
}
.bilibili-video-container:not([data-max-width]) .bilibili-iframe-container {
    max-width: calc(100% - 12px)!important;
    max-width: calc(100% - 12px)!important;
}
}
.onshow .bilibili-iframe-container {
.bilibili-video-container:not([data-max-width]).onshow .bilibili-iframe-container {
    max-height: calc(100% - 27px)!important;
    max-height: calc(100% - 27px)!important;
}
}
第109行: 第110行:
}
}
</style><script>
</style><script>
window.RLQ.push(function() {
/* eslint-disable no-loop-func */
    $(function() {
/* eslint-disable no-constant-condition */
     'use strict';
/* eslint-disable no-magic-numbers */
/* global mw */
"use strict";
window.RLQ.push(function () {
    $(function () {
      if (mw.config.get("AnnTools-BilibiliVideo-running", false)) {
      if (mw.config.get("AnnTools-BilibiliVideo-running", false)) {
        return;
        return;
      }
      }
      mw.config.set("AnnTools-BilibiliVideo-running", true);
      mw.config.set("AnnTools-BilibiliVideo-running", true);
      var isNaN = Number.isNaN || window.isNaN;
      const isNaN = Number.isNaN || window.isNaN;
      const temp = new Set();
      const temp = new Set();
     const cssLengthUnitValidator = (length, defaultValue, callback) => {
       if (typeof length !== "string" || length.length === 0) {
         callback(false);
         return defaultValue;
       }
       const parsedNumber = parseFloat(length.replace(/[a-z]+/i, ""));
       if (isNaN(parsedNumber) || parsedNumber <= 0) {
         callback(false);
         return defaultValue;
       }
       if (/^(?:\d+|\d*\.\d+)(?:em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|Q|in|pc|pt|px|%)$/.test(length)) {
         callback(true);
         return length;
       }
       if (/^(?:\d+|\d*\.\d+)$/.test(length)) {
         callback(true);
         return `${length}px`;
       }
       callback(false);
       return defaultValue;
     };
      class Converter {
      class Converter {
        constructor() {
        constructor() {
第135行: 第161行:
          } else if (bv.length === 9) {
          } else if (bv.length === 9) {
            return `BV1${bv}`;
            return `BV1${bv}`;
         } else {
           throw new Error("BV's length must be 9, 10 or 12");
          }
          }
         throw new Error("BV's length must be 9, 10 or 12");
        }
        }
        _bvidToAid(bvid) {
        _bvidToAid(bvid) {
          let r = 0;
          let r = 0;
          for (let i = 0; i < 6; i++) {
          for (let i = 0; i < 6; i++) {
            r += this._base58Table.indexOf(bvid[this._digitMap[i]]) * (58 ** i);
            r += this._base58Table.indexOf(bvid[this._digitMap[i]]) * 58 ** i;
          }
          }
          return 'av' + ((r - this._add) ^ this._xor);
          return "av" + (r - this._add ^ this._xor);
        }
        }
        bvidToAid(str) {
        bvidToAid(str) {
第154行: 第180行:
          if (/^av/i.test(av)) {
          if (/^av/i.test(av)) {
            return av;
            return av;
         } else {
           return `av${av}`;
          }
          }
         return `av${av}`;
        }
        }
        _aidToBvid(aid) {
        _aidToBvid(aid) {
第173行: 第199行:
      }
      }
      const converter = new Converter();
      const converter = new Converter();
      if (mw.config.get('skin') === 'minerva') $('.bilibili-video-container:not(.bilibili-video-initialized)').each(function() {
      if (mw.config.get("skin") === "minerva") {
       var element = $(this),
       $(".bilibili-video-container:not(.bilibili-video-initialized)").each(function () {
         dataset = this.dataset;
         const element = $(this),
       element.addClass("bilibili-video-initialized");
           dataset = this.dataset;
       var _id = dataset.id,
         element.addClass("bilibili-video-initialized");
         id = _id.replace(/^[ab]v/i, ''),
         const _id = dataset.id,
         title = dataset.title,
           id = _id.replace(/^[ab]v/i, ""),
         pagename = dataset.pagename,
           title = dataset.title,
         page = parseInt(dataset.page),
           pagename = dataset.pagename,
         t = parseInt(dataset.t),
           page = parseInt(dataset.page),
         tIsInvalid = isNaN(t) || t <= 0,
           t = parseInt(dataset.t),
         subtitle = dataset.subtitle === 'true' ? true : false;
           tIsInvalid = isNaN(t) || t <= 0,
       var prefix;
           subtitle = dataset.subtitle === "true" ? true : false;
       var decode = null;
         let prefix;
       if (/^(?:av)?\d{1,9}$/i.test(_id)) {
         let decode = null;
         prefix = {
         if (/^(?:av)?\d{1,9}$/i.test(_id)) {
           href: "av",
           prefix = {
           iframe: "aid"
             href: "av",
         };
             iframe: "aid",
       } else if (/^(?:bv)?[\da-z]{10}$/i.test(_id)) {
           };
         prefix = {
         } else if (/^(?:bv)?[\da-z]{10}$/i.test(_id)) {
           href: "BV",
           prefix = {
           iframe: "bvid"
             href: "BV",
         };
             iframe: "bvid",
         if (!/[bB][vV][fZodR9XQDSUm21yCkr6zBqiveYah8bt4xsWpHnJE7jL5VG3guMTKNPAwcF]{10}/.test(_id)) {
           };
           temp.add(_id);
           if (!converter._bvidRegExp.test(_id)) {
             temp.add(_id);
           } else {
             decode = converter.bvidToAid(_id);
           }
          } else {
          } else {
            decode = converter.bvidToAid(_id);
            if (/^(?:av)?\d{10,}$/i.test(_id)) {
             temp.add(_id);
           }
           return this.outerHTML = "<i>id错误</i>";
          }
          }
       } else {
          $.ajax({
          if (/^(?:av)?\d{10,}$/i.test(_id)) {
            url: "https://mgwbcprd.azureedge.net/BilibiliMeta/Index/" + encodeURIComponent(typeof decode === "string" ? decode : prefix.href + id),
            temp.add(_id);
           type: "GET",
         }
           timeout: 10000,
         return this.outerHTML = "<i>id错误</i>";
           success: function (data) {
       }
             const list = data.VideoEntities
       $.ajax({
               .map(function (e, i) {
         url: 'https://mgwbcprd.azureedge.net/BilibiliMeta/Index/' + encodeURIComponent(typeof decode === "string" ? decode : prefix.href + id),
                 e.page = i + 1;
         type: 'GET',
                 e.title = e.Title.replace(/^\d+、/, "");
         success: function(data) {
                 return e;
           var list = data.VideoEntities
               });
             .map(function(e, i) {
              let _page = 1;
               e.page = i + 1;
              const name = title || (data.Title ? data.Title : prefix.href + id);
               e.title = e.Title.replace(/^\d+、/, '');
              let index;
               return e;
              let length;
             }),
             if (pagename) {
              _page = 1,
               for (index = 0, length = list.length; index < length; index++) {
              name = title || (data.Title ? data.Title : prefix.href + id),
                 if (list[index].Title !== pagename && list[index].title !== pagename) { continue; }
              index,
                 _page = list[index].page;
              length;
                 break;
           if (pagename) {
               }
             for (index = 0, length = list.length; index < length; index++) {
             } else { _page = page; }
               if (list[index].Title !== pagename && list[index].title !== pagename) continue;
             index = _page - 1;
               _page = list[index].page;
             let sec = t % 60 + "";
                break;
             if (sec.length === 1) { sec = "0" + sec; }
             const time = Math.floor(t / 60) + ":" + sec;
             const button = $("<a/>").addClass("bilibili-video-button").attr("rel", "nofollow noreferrer noopener").attr("href", "https://www.bilibili.com/video/" + prefix.href + id + "?p=" + _page + (tIsInvalid ? "" : "&t=" + t)).text(name + " [" + _page + "/" + list.length + "]" + (tIsInvalid ? "" : "[跳转至" + time + "]"));
             if (list[index] !== undefined && list[index].VideoCid !== undefined && subtitle) {
                button.append("<br>(" + _page + "、" + list[index].Title + ")");
              }
              }
           } else _page = page;
              element.before(button).remove();
           index = _page - 1;
           },
           var sec = t % 60 + '';
           error: function () {
           if (sec.length === 1) sec = '0' + sec;
             element.before($("<a/>").addClass("bilibili-video-button").attr("rel", "nofollow noreferrer noopener").attr("href", "https://www.bilibili.com/video/" + prefix.href + id + "?p=" + page + (tIsInvalid ? "" : "&t=" + t)).text((title || prefix.href + id) + ([0, 1].indexOf(page) !== -1 && !isNaN(page) ? " (P" + page + ")" : ""))).remove();
           var time = Math.floor(t / 60) + ':' + sec;
           },
           var button = $('<a/>').addClass('bilibili-video-button').attr("rel", "nofollow noreferrer noopener").attr('href', "https://www.bilibili.com/video/" + prefix.href + id + "?p=" + _page + (tIsInvalid ? '' : '&t=' + t)).text(name + ' [' + _page + '/' + list.length + ']' + (tIsInvalid ? '' : '[跳转至' + time + ']'));
          });
           if (list[index] !== undefined && list[index].VideoCid !== undefined && subtitle) {
              button.append('<br>(' + _page + '、' + list[index].Title + ')');
           }
           element.before(button).remove();
         },
         error: function(e) {
           element.before($('<a/>').addClass('bilibili-video-button').attr("rel", "nofollow noreferrer noopener").attr('href', "https://www.bilibili.com/video/" + prefix.href + id + "?p=" + page + (tIsInvalid ? '' : '&t=' + t)).text((title || prefix.href + id) + ([0, 1].indexOf(page) !== -1 && !isNaN(page) ? ' (P' + page + ')' : ''))).remove();
          },
        });
        });
      });
      }
      else {
      else {
        var global_element = $('#mw-content-text');
        const global_element = $("#mw-content-text");
        window.widget = window.widget || {};
        window.widget = window.widget || {};
        window.widget.bilibili = {
        window.widget.bilibili = {
第256行: 第285行:
          }
          }
          running = true;
          running = true;
          let target = widget.bilibili.iframes.shift();
          while (true) {
         while (target) {
           const target = window.widget.bilibili.iframes.shift();
           await new Promise((res) => {
           if (target) {
             target.addEventListener("load", () => {
             await new Promise((res) => {
                running = false;
               target.addEventListener("load", () => {
                target = widget.bilibili.iframes.shift();
                 res();
               res();
                });
                target.src = target.dataset.src;
              });
              });
              target.src = target.dataset.src;
           } else {
            });
              running = false;
             return;
            }
          }
          }
        };
        };
第273行: 第305行:
          "intersectionRatio" in window.IntersectionObserverEntry.prototype &&
          "intersectionRatio" in window.IntersectionObserverEntry.prototype &&
          "isIntersecting" in window.IntersectionObserverEntry.prototype) {
          "isIntersecting" in window.IntersectionObserverEntry.prototype) {
          lazyLoadObserver = new IntersectionObserver(function(entries) {
          lazyLoadObserver = new IntersectionObserver(function (entries) {
            entries.forEach(function(entry) {
            entries.forEach(function (entry) {
              if (entry.isIntersecting) {
              if (entry.isIntersecting) {
                const lazyTarget = entry.target;
                const lazyTarget = entry.target;
                widget.bilibili.iframes.push(lazyTarget);
                window.widget.bilibili.iframes.push(lazyTarget);
                loop();
                loop();
                lazyLoadObserver.unobserve(lazyTarget);
                lazyLoadObserver.unobserve(lazyTarget);
第286行: 第318行:
          lazyLoadObserver = {
          lazyLoadObserver = {
            observe: (ele) => {
            observe: (ele) => {
              widget.bilibili.iframes.push(ele);
              window.widget.bilibili.iframes.push(ele);
              loop();
              loop();
            }
            },
          }
          };
        }
        }
        var iframe_href_base = 'https://www.bilibili.com/blackboard/newplayer.html?playlist=true&playlist_order=sequential&musth5=1&noEndPanel=1&crossDomain=1&autoplay=0&';
        const iframe_href_base = "https://www.bilibili.com/blackboard/newplayer.html?playlist=true&playlist_order=sequential&musth5=1&noEndPanel=1&crossDomain=1&autoplay=0&";
        var EPSILON = 2.220446049250313e-16,
        const EPSILON = 2.220446049250313e-16,
          rememberWH = function rememberWH(ele) {
          rememberWH = function rememberWH(ele) {
            ele.data({ width: ele.width(), height: ele.height() });
            ele.data({ width: ele.width(), height: ele.height() });
          },
          },
          setTureHeight = function setTureHeight(ele) {
          setTureHeight = function setTureHeight(ele) {
            var barHeight = ele.data('height') - ele.data('width') * 9 / 16; //计算标题和播放器控制栏高度
            const barHeight = ele.data("height") - ele.data("width") * 9 / 16; //计算标题和播放器控制栏高度
            ele.height(ele.width() * 9 / 16 + barHeight);
            ele.height(ele.width() * 9 / 16 + barHeight);
          },
          },
          setWH = function setWH(ele) {
          setWH = function setWH(ele) {
            ele.css({ width: '100%', height: '100%' });
            ele.css({ width: "100%", height: "100%" });
          },
          },
          recallWH = function recallWH(ele) {
          recallWH = function recallWH(ele) {
            ele.width(ele.data('width')).height(ele.data('height'));
            ele.width(ele.data("width")).height(ele.data("height"));
          },
          },
          setMaxHeight = function setMaxHeight(container, target) {
          setMaxHeight = function setMaxHeight(container, target) {
            var h = container.outerHeight(true);
            const h = container.outerHeight(true);
            var t = 0;
            let t = 0;
            container.children().each(function() {
            container.children().each(function () {
              t += $(this).outerHeight(true);
              t += $(this).outerHeight(true);
            });
            });
            target.css('max-height', 'calc(100% - ' + parseInt(t - h + 2 - (Number.EPSILON || EPSILON)) + 'px)');
            target.css("max-height", "calc(100% - " + parseInt(t - h + 2 - (Number.EPSILON || EPSILON)) + "px)");
          };
          };
        $('.bilibili-video-container').addClass('exec').each(function() {
        $(".bilibili-video-container").addClass("exec").each(function () {
          var dataset = this.dataset,
          const dataset = this.dataset,
            _id = dataset.id,
            _id = dataset.id,
            id = _id.replace(/^[ab]v/i, ''),
            id = _id.replace(/^[ab]v/i, ""),
            selfbox = $(this);
            selfbox = $(this);
          var prefix;
          let prefix;
          var decode = null;
          let decode = null;
          if (/^(?:av)?\d{1,9}$/i.test(_id)) {
          if (/^(?:av)?\d{1,9}$/i.test(_id)) {
            prefix = {
            prefix = {
              href: "av",
              href: "av",
              iframe: "aid"
              iframe: "aid",
            };
            };
          } else if (/^(?:bv)?[\da-z]{10}$/i.test(_id)) {
          } else if (/^(?:bv)?[\da-z]{10}$/i.test(_id)) {
            prefix = {
            prefix = {
              href: "BV",
              href: "BV",
              iframe: "bvid"
              iframe: "bvid",
            };
            };
            if (!/[bB][vV][fZodR9XQDSUm21yCkr6zBqiveYah8bt4xsWpHnJE7jL5VG3guMTKNPAwcF]{10}/.test(_id)) {
            if (!converter._bvidRegExp.test(_id)) {
              temp.add(_id);
              temp.add(_id);
            } else {
            } else {
第342行: 第374行:
            return this.outerHTML = "<i>id错误</i>";
            return this.outerHTML = "<i>id错误</i>";
          }
          }
          var page = parseInt(+(dataset.page || 1)),
          let page = parseInt(+(dataset.page || 1));
           pagename = dataset.pagename,
         const pagename = dataset.pagename;
           title = dataset.title,
         const title = dataset.title;
           height = +dataset.height || 441,
         const height = cssLengthUnitValidator(dataset.height, "441px", (isValidated) => isValidated || $(this).removeAttr("data-height"));
           width = +dataset.width || 665,
         const width = cssLengthUnitValidator(dataset.width, "665px", (isValidated) => isValidated || $(this).removeAttr("data-width"));
           subtitle = dataset.subtitle === 'true' ? true : false,
         const maxHeight = cssLengthUnitValidator(dataset.maxHeight, undefined, (isValidated) => isValidated || $(this).removeAttr("data-max-height"));
           t = parseInt(dataset.t),
         const maxWidth = cssLengthUnitValidator(dataset.maxWidth, undefined, (isValidated) => isValidated || $(this).removeAttr("data-max-width"));
           tIsInvalid = isNaN(t) || t <= 0,
         const subtitle = dataset.subtitle === "true" ? true : false;
           iframeContainer = $(this).find('.bilibili-iframe-container'),
         const t = parseInt(dataset.t);
           title_text = $('<a/>').attr("rel", "nofollow noreferrer noopener").addClass('external text').attr({
         const tIsInvalid = isNaN(t) || t <= 0;
             href: "https://www.bilibili.com/video/" + prefix.href + id + "?p=" + page + (tIsInvalid ? '' : '&t=' + t),
         const iframeContainer = $(this).find(".bilibili-iframe-container");
             target: '_blank',
         const title_text = $("<a/>").attr("rel", "nofollow noreferrer noopener").addClass("external text").attr({
           }).prependTo($(this).find('.bilibili-title')),
           href: "https://www.bilibili.com/video/" + prefix.href + id + "?p=" + page + (tIsInvalid ? "" : "&t=" + t),
           iframe = $('<iframe/>').attr({
           target: "_blank",
             frameborder: 0,
         }).prependTo($(this).find(".bilibili-title"));
             scrolling: 'no',
         const iframe = $("<iframe/>").attr({
             src: '',
           frameborder: 0,
             allowfullscreen: true,
           scrolling: "no",
             class: "bilibili-iframe",
           src: "",
           }).css({
           allowfullscreen: true,
             width: width,
           "class": "bilibili-iframe",
             height: height,
         }).css({
           });
         if (!tIsInvalid) selfbox.removeAttr("data-auto-expand");
         if (isNaN(page) || page < 1) page = 1;
         if (isNaN(width)) width = 665;
         if (isNaN(height)) height = 441;
         var sec = t % 60 + '';
         if (sec.length === 1) sec = '0' + sec;
         var time = Math.floor(t / 60) + ':' + sec;
         title_text.text((title || prefix.href + id) + ([0, 1].indexOf(page) === -1 ? ' (' + page + ')' : '') + (tIsInvalid ? '' : '[视频从' + time + '开始播放]'));
         iframeContainer.css({
            width: width,
            width: width,
            height: height,
            height: height,
          }).find(".bilibili-iframe-overlay").css({
           "max-width": maxWidth,
           "max-height": maxHeight,
          });
         if (!tIsInvalid) { selfbox.removeAttr("data-auto-expand"); }
         if (isNaN(page) || page < 1) { page = 1; }
         let sec = t % 60 + "";
         if (sec.length === 1) { sec = "0" + sec; }
         const time = Math.floor(t / 60) + ":" + sec;
         title_text.text((title || prefix.href + id) + ([0, 1].indexOf(page) === -1 ? " (" + page + ")" : "") + (tIsInvalid ? "" : "[视频从" + time + "开始播放]") + "【视频信息加载中……】");
         iframeContainer.css({
            width: width,
            width: width,
            height: height,
            height: height,
          }).text('正在加载,请稍候……');
           "max-width": maxWidth,
          iframe.appendTo(iframeContainer.empty());
           "max-height": maxHeight,
          window.setTimeout(function() { //异步出去不要卡主线程
          });
          iframe.appendTo(iframeContainer);
          window.setTimeout(function () { //异步出去不要卡主线程
            $.ajax({
            $.ajax({
              url: 'https://mgwbcprd.azureedge.net/BilibiliMeta/Index/' + encodeURIComponent(typeof decode === "string" ? decode : prefix.href + id),
              url: "https://mgwbcprd.azureedge.net/BilibiliMeta/Index/" + encodeURIComponent(typeof decode === "string" ? decode : prefix.href + id),
              type: 'GET',
              type: "GET",
              success: function(data) {
             timeout: 10000,
                var list = data.VideoEntities
              success: function (data) {
                  .map(function(e, i) {
                const list = data.VideoEntities
                  .map(function (e, i) {
                    e.page = i + 1;
                    e.page = i + 1;
                    e.title = e.Title.replace(/^\d+、/, '');
                    e.title = e.Title.replace(/^\d+、/, "");
                    return e;
                    return e;
                  }),
                  });
                 _page = 1,
               let _page = 1;
                 name = title || (data.Title ? data.Title : prefix.href + id),
               const name = title || (data.Title ? data.Title : prefix.href + id);
                 index,
               let index;
                 length;
               let length;
                if (pagename) {
                if (pagename) {
                  for (index = 0, length = list.length; index < length; index++) {
                  for (index = 0, length = list.length; index < length; index++) {
                    if (list[index].Title !== pagename && list[index].title !== pagename) continue;
                    if (list[index].Title !== pagename && list[index].title !== pagename) { continue; }
                    _page = list[index].page;
                    _page = list[index].page;
                    break;
                    break;
                  }
                  }
                } else _page = page;
                } else { _page = page; }
                index = _page - 1;
                index = _page - 1;
                var href = title_text.attr('href');
                const href = title_text.attr("href");
                if (list[index] !== undefined && list[index].VideoCid !== undefined) {
                if (list[index] !== undefined && list[index].VideoCid !== undefined) {
                  iframe.attr('data-src', iframe_href_base + prefix.iframe + '=' + id + '&page=' + _page + (tIsInvalid ? '' : '&t=' + t));
                  iframe.attr("data-src", iframe_href_base + prefix.iframe + "=" + id + "&page=" + _page + (tIsInvalid ? "" : "&t=" + t));
                  title_text.attr('href', href.replace(new RegExp("\\?p=" + page, 'g'), "?p=" + _page));
                  title_text.attr("href", href.replace(new RegExp("\\?p=" + page, "g"), "?p=" + _page));
                  title_text.text(name + ' [' + _page + '/' + list.length + ']' + (tIsInvalid ? '' : '[视频从' + time + ' 开始播放]'));
                  title_text.text(name + " [" + _page + "/" + list.length + "]" + (tIsInvalid ? "" : "[视频从" + time + " 开始播放]"));
                  if (subtitle) title_text.append('<br>(' + _page + ' ' + list[index].Title + ' ');
                  if (subtitle) { title_text.append("<br>(" + _page + " " + list[index].Title + " "); }
                } else {
                } else {
                  title_text.text(name + (tIsInvalid ? '' : '[视频从' + time + ' 开始播放]'));
                  title_text.text(name + (tIsInvalid ? "" : "[视频从" + time + " 开始播放]"));
                  iframe.attr('data-src', iframe_href_base + prefix.iframe + '=' + id + '&page=' + _page + (tIsInvalid ? '' : '&t=' + t));
                  iframe.attr("data-src", iframe_href_base + prefix.iframe + "=" + id + "&page=" + _page + (tIsInvalid ? "" : "&t=" + t));
                }
                }
                lazyLoadObserver.observe(iframe[0]);
                lazyLoadObserver.observe(iframe[0]);
              },
              },
              error: function(e) {
              error: function (e) {
                title_text.text((title || prefix.href + id) + ([0, 1].indexOf(page) === -1 ? ' (' + page + ')' : '') + (tIsInvalid ? '' : '[视频从' + time + ' 开始播放]'));
                title_text.text((title || prefix.href + id) + ([0, 1].indexOf(page) === -1 ? " (" + page + ")" : "") + (tIsInvalid ? "" : "[视频从" + time + " 开始播放]"));
                if (e && e.responseJSON && e.responseJSON.message && e.responseJSON.message === "Authentication is required for accessing this video.") title_text.parent().append('<sup title="“Bilibili采用会员制,大部分投稿视频会员与游客都可以观看,\n  但部分视频在UP主设定下只有会员才可以观看(这些视频常被称为‘只有会员才知道的世界’)。”\n  - Bilibili#用户制度 @ ZhMoegirl\n在这种情况下我们无法为您解析视频及其分P标题、分P数量等。">(只有会员才知道的世界)</sup>');
                if (e && e.responseJSON && e.responseJSON.message && e.responseJSON.message === "Authentication is required for accessing this video.") { title_text.parent().append('<sup title="“Bilibili采用会员制,大部分投稿视频会员与游客都可以观看,\n  但部分视频在UP主设定下只有会员才可以观看(这些视频常被称为‘只有会员才知道的世界’)。”\n  - Bilibili#用户制度 @ ZhMoegirl\n在这种情况下我们无法为您解析视频及其分P标题、分P数量等。">(只有会员才知道的世界)</sup>'); }
                iframe.attr('data-src', iframe_href_base + prefix.iframe + '=' + id + '&page=' + page + (tIsInvalid ? '' : '&t=' + t));
                iframe.attr("data-src", iframe_href_base + prefix.iframe + "=" + id + "&page=" + page + (tIsInvalid ? "" : "&t=" + t));
                lazyLoadObserver.observe(iframe[0]);
                lazyLoadObserver.observe(iframe[0]);
              },
              },
第425行: 第459行:
          }, 137);
          }, 137);
          //toggle
          //toggle
          selfbox.find('.bilibili-toggle').on('click', function() {
          selfbox.find(".bilibili-toggle").on("click", function () {
            selfbox.width(iframeContainer.outerWidth(true));
            selfbox.width(iframeContainer.outerWidth(true));
            selfbox.toggleClass('onshow');
            selfbox.toggleClass("onshow");
            iframeContainer.toggle();
            iframeContainer.toggle();
            if ($(this).text() === ' 显示视频') {
            if ($(this).text() === " 显示视频") {
              $(this).text(' 隐藏视频');
              $(this).text(" 隐藏视频");
              $(window).resize();
              $(window).resize();
            } else {
            } else {
              $(this).text(' 显示视频');
              $(this).text(" 显示视频");
              selfbox.removeAttr('style');
              selfbox.removeAttr("style");
            }
            }
          });
          });
          selfbox.find('.bilibili-widescreen').on('click', function() {
          selfbox.find(".bilibili-widescreen").on("click", function () {
            if (selfbox.is(':not(.onshow)')) return;
            if (selfbox.is(":not(.onshow)")) { return; }
            if (selfbox.is('.widescreen')) {
            if (selfbox.is(".widescreen")) {
              selfbox.removeClass('widescreen');
              selfbox.removeClass("widescreen");
              $(this).text(' 显示宽屏');
              $(this).text(" 显示宽屏");
              recallWH(iframeContainer);
              recallWH(iframeContainer);
              recallWH(iframe);
              recallWH(iframe);
              recallWH(selfbox);
              recallWH(selfbox);
            } else {
            } else {
              selfbox.addClass('widescreen');
              selfbox.addClass("widescreen");
              $(this).text(' 退出宽屏');
              $(this).text(" 退出宽屏");
              rememberWH(selfbox);
              rememberWH(selfbox);
              selfbox.css('width', selfbox.parent().width() > Math.min(911, global_element.width()) ? '73%' : '100%'); //可以看见按钮的最小宽度 665 的 1/0.73 倍
              selfbox.css("width", selfbox.parent().width() > Math.min(911, global_element.width()) ? "73%" : "100%"); //可以看见按钮的最小宽度 665 的 1/0.73 倍
              setTureHeight(selfbox);
              setTureHeight(selfbox);
              rememberWH(iframe);
              rememberWH(iframe);
第460行: 第494行:
          });
          });
        });
        });
        $(window).on('resize', function() {
        $(window).on("resize", function () {
          $('.bilibili-video-container.onshow.widescreen').each(function() {
          $(".bilibili-video-container.onshow.widescreen").each(function () {
            var selfbox = $(this);
            const selfbox = $(this);
            selfbox.css('width', selfbox.parent().width() > Math.min(911, global_element.width()) ? '73%' : '100%');
            selfbox.css("width", selfbox.parent().width() > Math.min(911, global_element.width()) ? "73%" : "100%");
            setTureHeight(selfbox);
            setTureHeight(selfbox);
            setMaxHeight(selfbox, selfbox.find('.bilibili-iframe-container'));
            setMaxHeight(selfbox, selfbox.find(".bilibili-iframe-container"));
          });
          });
        });
        });
        setTimeout(function() {
        setTimeout(function () {
          $('.bilibili-video-container.exec[data-auto-expand="true"]').find('.bilibili-toggle').click();
          $('.bilibili-video-container.exec[data-auto-expand="true"]').find(".bilibili-toggle").click();
        }, 100);
        }, 100);
      }
      }
第476行: 第510行:
          const raw = await $.get("https://zh.moegirl.org/User:AnnAngela/SandBox/bvid?action=raw&ctype=application/json&_=" + Math.random());
          const raw = await $.get("https://zh.moegirl.org/User:AnnAngela/SandBox/bvid?action=raw&ctype=application/json&_=" + Math.random());
          let flags = false;
          let flags = false;
          for (let i of temp) {
          for (const i of temp) {
            if (!(i in raw)) {
            if (!(i in raw)) {
              flags = true;
              flags = true;
第487行: 第521行:
              title: "User:AnnAngela/SandBox/bvid",
              title: "User:AnnAngela/SandBox/bvid",
              text: JSON.stringify(raw),
              text: JSON.stringify(raw),
              summary: "[[Widget:BilibiliVideo|BilibiliVideo]]:bvid不符合格式 - " + submit.filter(bvid => !raw.includes(bvid)).join(", "),
              summary: "[[Widget:BilibiliVideo|BilibiliVideo]]:bvid不符合格式 - " + Array.from(temp.values()).filter(bvid => !raw.includes(bvid)).join(", "),
              tags: "Automation tool",
              tags: "Automation tool",
              minor: true,
              minor: true,
第494行: 第528行:
              watchlist: "nochange",
              watchlist: "nochange",
              contentformat: "application/json",
              contentformat: "application/json",
              contentmodel: "json"
              contentmodel: "json",
            });
            });
          }
          }

2020年5月27日 (三) 14:32的版本

名称: Bilibili视频插件
作者: 加大号的猫
修订: Boxsnake
重修订: AnnAngela
H5版再修订:
新H5版又修订:
移动版支持: XYZ指示物
版权协定: MIT
发布日期:

2012年6月29日第一版发布;
2015年2月6日更新;
2016年11月29日更新更多细节;
2017年4月10日更新至H5版(感谢众多dalao的debug_(:зゝ∠)_);
2020年01月27日更新至新版H5播放器。

发布地址: https://zh.moegirl.org.cn/Widget:BilibiliVideo && https://zh.moegirl.org.cn/Template:BilibiliVideo
注意事项: 如有问题,请联系作者。

本Widget不能单独使用,请使用{{BilibiliVideo}}!