Greasy Fork

Cetak Sekaligus Kertas A6

Untuk mencetak multi print buat kertas ukuran A6 untuk Tokopedia, Bukalapak dan Shopee

目前为 2018-08-31 提交的版本。查看 最新版本

// ==UserScript==
// @name         Cetak Sekaligus Kertas A6
// @author       Celleven Store
// @namespace    https://www.tokopedia.com/celleven
// @version      0.0.2
// @description  Untuk mencetak multi print buat kertas ukuran A6 untuk Tokopedia, Bukalapak dan Shopee
// @require      https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js
// @match        https://www.tokopedia.com/print-address.pl*
// @match        https://seller.shopee.co.id/api/v2/orders/waybill*
// @run-at       document-idle
// ==/UserScript==

(function() {
  'use strict';

  var backgroundImage = '';
  var logo = '';

  if (window.location.href.indexOf("tokopedia") > -1)
  {
    cetakTokopedia();
  }
  else if (window.location.href.indexOf("shopee") > -1)
  {
    cetakShopee();
  }
  else if (window.location.href.indexOf("bukalapak") > -1)
  {
    cetakBukalapak();
  }

})();

function cetakTokopedia()
{
  var styleCSS = `<style>
  @page
  {
    size: 105mm 148mm portrait;
    margin: 3mm 2mm 2mm 3mm;
  }
  @media print
  {
    div.address_contaier_left, div.address_contaier_right, div.address
    {
      float: none !important;
      padding-left: 0px;
    }
    div.address
    {
      page-break-after: always;
    }
    body
    {
      zoom: 117%;
    }
    h5
    {
      display: none;
    }
  }
  </style>`;

  $('body').append(styleCSS);
  $('div.address > table > tbody > tr > td').each(function(x, r)
  {
    if ($(r).find('table').length == 5)
    {
      $(r).find('table:nth-child(4) > tbody > tr > td > div').css('font-size', '15px');
    }
    else if ($(r).find('table').length == 7 || $(r).find('table').length == 6)
    {
      $(r).find('table:nth-child(5) > tbody > tr > td > div').css('font-size', '15px');
    }
  });

  $("table div:contains('bayar asuransi')").remove();
  $("td div:contains('Asuransi')").next().html('+ Rp 0').css('text-decoration', 'none');
  $("td div:contains('Ongkir')").next().css('text-decoration', 'none');
}

function cetakShopee()
{
  var styleCSS = `<style>
  @page
  {
    margin: 4mm 1mm 2mm 4mm;
  }
  @media print
  {
    .page
    {
      float: none !important;
      page-break-after: always;
      border-right: none !important;
      width: 48%;
    }
    .left
    {
      margin-left: -1px;
    }
  }
  </style>`;

  $('style:last').html($('style:last').html().replace('A4 landscape', 'auto'));
  $('head').append(styleCSS);
  $('div.page-breaker').remove();
  $('div:last').remove();
  $('img.scissors-vertical').remove();
}

function cetakBukalapak()
{
}