Google Drive Preview Link button

Create a button to go to the preview link in the Google Drive File link.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         Google Drive Preview Link button
// @name:ko      구글드라이브 미리보기 링크 버튼
// @version      0.3.2
// @description  Create a button to go to the preview link in the Google Drive File link.
// @description:ko   구글드라이브 파일링크에서 미리보기 링크로 이동하는 버튼을 만듭니다.
// @author       Meda
// @match        https://drive.google.com/u*
// @match        https://docs.google.com/u*
// @grant        none
// @namespace https://greasyfork.org/users/319515
// ==/UserScript==

function getLang() {
  var userLang = navigator.language || navigator.userLanguage;
  return userLang;
}

(function() {
    var array = window.location.href.split("id=");
    var elem = document.getElementById('download-form');
    var newLink = document.createElement("a");
    newLink.setAttribute('style', 'margin-left:7px');
    newLink.setAttribute('href', 'https://drive.google.com/file/d/'+array[1].substr(0, 33)+'/edit');

    if(getLang()=="ko-KR"){
        newLink.innerHTML = '<button type="button" id="uc-download-preview">미리보기</button>';
    }else{
        newLink.innerHTML = '<button type="button" id="uc-download-preview">Preview</button>';
    }
    elem.append(newLink);
})();