Polyv Shorcode

Polyv Shorcode for wordpress.

Устаревшая версия за 09.02.2020. Перейдите к последней версии.

// ==UserScript==
// @name         Polyv Shorcode
// @namespace    https://www.iplaysoft.com
// @version      0.1
// @description  Polyv Shorcode for wordpress.
// @author       X-Force
// @match        http://my.polyv.net/*
// @match        https://my.polyv.net/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    if(window.location.protocol != "https:"){
        var newUrl = window.location.href.replace("http://", "https://");
        window.location=newUrl;
    }

    var template = '[video url="{{url}}" youku="" vqq="" bilibili=""]{{url}}[/video]';
    var urlBase = 'https://share.polyv.net/front/video/preview?vid=';

    var vids = document.getElementsByClassName("time-vid-content");
    for(var i=0;i<vids.length;i++){
        var id = vids[i].innerText;
        var url= urlBase+id;
        var data= template.replace(/{{url}}/g,url);
        var copy = vids[i].getElementsByClassName("copy-vid")[0];
        copy.setAttribute('data-clipboard-text',data);
    }
})();