1688 HaveId No Image

get 1688 main_image and product name

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         1688 HaveId No Image
// @name:zh-CN   1688 HaveId No Image
// @namespace    com.hct.contrast
// @icon         https://lk-data-collection.oss-cn-qingdao.aliyuncs.com/winner/winnercoupang/Icon.png
// @version      1.0
// @description  get 1688 main_image and product name
// @description:zh-cn   1688有goods_id但是没有主图信息
// @author       hansel
// @include      https://detail.1688.com/*
// @grant        GM_xmlhttpRequest
// @require      https://code.jquery.com/jquery-1.12.4.min.js
// ==/UserScript==
var api_url = "http://operate.hagoto.com/admin/api/";
var sp_mbd_id = "";
(function() {
    'use strict';
    var cur_url = document.location.href;
    if(cur_url.indexOf("sp_mbd_id=")>0){
        var keydatas = cur_url.split('sp_mbd_id=');
        sp_mbd_id = keydatas[1];
    }
    if(sp_mbd_id == ""){
        return;
    }
    var div = document.createElement("div");
    div.setAttribute("style", "width: 100%;height: 30px;position: fixed;left: 84%;bottom: 50%;height: 35px;line-height: 35px;color: #333;font-size: 14px;");
    var inner_html = '<button class="btn-confirm">mbd获取主图信息</button>';
    div.innerHTML = inner_html;
    document.body.appendChild(div);

    $(".btn-confirm").attr("style","border: none;width: 120px;height: 33px;color: #fff;background: red;cursor: pointer;");

    //选用
    $('.btn-confirm').on('click', function (e) {
        var main_image = $(".mod-detail-gallery").find(".tab-pane").find("a.box-img").find("img").attr("src");
        var product_name = $("#mod-detail-title").find(".d-title").text();
        main_image = main_image.trim();
        product_name = product_name.trim();
        var datajson = {
            "sp_mbd_id":sp_mbd_id,
            "main_image":main_image,
            "product_name":product_name,
        };
        GM_xmlhttpRequest({
            method: "POST",
            url: api_url +"setBMDAlibabaInfo",
            dataType: "json",
            data: JSON.stringify(datajson),
            headers: {
                "Content-Type": "application/json"
            },
            onload: function(result) {
                console.log(result);
                if(result.readyState==4&&result.status==200){
                    var dataJson = JSON.parse(result.response);
                    alert(dataJson.msg);
                }
            }
        })
    });



})();