Greasy Fork

Greasy Fork is available in English.

阿里巴巴商品关键词获取

自动获取阿里巴巴商品收录关键词并展示在详情页顶部

当前为 2019-12-02 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @icon             https://www.thfou.com/img/favicon.png
// @name             阿里巴巴商品关键词获取
// @namespace        https://www.thfou.com/
// @version          2.1.2
// @description      自动获取阿里巴巴商品收录关键词并展示在详情页顶部
// @author           头号否
// @match            *://detail.1688.com/offer/*
// @require          https://libs.baidu.com/jquery/1.10.2/jquery.min.js
// @supportURL       https://www.thfou.com/liuyan
// @compatible	     Chrome
// @compatible	     Firefox
// @compatible	     Edge
// @compatible   	 Safari
// @compatible   	 Opera
// @compatible	     UC
// @license          GPL-3.0-only
// ==/UserScript==

(function() {
    'use strict';
setTimeout(function(){
   var style = document.createElement('style');
   style.type = 'text/css';
   style.innerHTML=".thfou-1688-tools{width:100%;height:46px;margin-top:-10px;margin-bottom:5px;background-color:rgb(242, 242, 242);}.thfou-1688-tools .item{width:auto;height:46px;float:left;margin:0px 5px 0px 10px;}.thfou-1688-tools .item p{display:inline-block;width:auto;height:46px;line-height:46px;}.thfou-1688-tools .item > span{display:inline-block;width:auto;height:46px;line-height:46px;color:rgb(255, 42, 0);}.data-content-tools{width:100%;height:46px;margin-top:10px;margin-bottom:5px;background-color:rgb(242, 242, 242);}.thfou-1688-tools .data-content-tools > .btn{width:auto;height:26px;line-height:26px;background-color:rgb(30, 159, 255);color:rgb(242, 242, 242);float:right;cursor:pointer;margin:10px 15px 10px 0px;padding:0px 5px;border-radius:2px;}.thfou-1688-slinfo{width:100%;height:46px;margin-top:-10px;margin-bottom:5px;background-color:rgb(242, 242, 242);}.thfou-1688-slinfo .item{width:auto;height:46px;float:left;margin:0px 5px 0px 10px;}.thfou-1688-slinfo .item p{display:inline-block;width:auto;height:46px;line-height:46px;}.thfou-1688-slinfo .item > span{display:inline-block;width:auto;height:46px;line-height:46px;color:rgb(255, 42, 0);}.data-slinfo-content{width:100%;height:46px;margin-top:10px;margin-bottom:5px;background-color:rgb(242, 242, 242);}.thfou-1688-slinfo .data-slinfo-content > .btn{width:auto;height:26px;line-height:26px;background-color:rgb(30, 159, 255);color:rgb(242, 242, 242);float:right;cursor:pointer;margin:10px 15px 10px 0px;padding:0px 5px;border-radius:2px;}#cp-addtag{margin-right:-10px;}.addtag{display:initial!important;background-color:rgb(65, 132, 243);color:rgb(255, 255, 255)!important;position:relative;margin-right:10px;padding:5px;border-radius:3px;}.addtag-arrow-r{background-color:rgb(65, 132, 243);position:absolute;right:-4px;width:8px;height:8px;transform:rotate(45deg);margin-top:18px;}.thflogo{width:40px;height:40px;margin:3px auto;border-radius:4px;}.data-1688-logo{width:42px;height:100%;float:left;margin-left:10px;}.inject-1688-ctn{margin-top:0px!important;margin-bottom:0px!important;};";
   document.getElementsByTagName('HEAD').item(0).appendChild(style);
//插入框架
var addbg = document.createElement('div');
    addbg.className = 'thfou-1688-tools';
    var getclass = document.querySelector('.region-horizontal');
    addbg.innerHTML = '<div class="data-content-tools"></div>';
    getclass.parentNode.insertBefore(addbg, getclass);
var slinfo = document.createElement('div');
    slinfo.className = 'thfou-1688-slinfo';
    var slinfoa = document.querySelector('.region-horizontal');
    slinfo.innerHTML = '<div class="data-slinfo-content"></div>';
    slinfoa.parentNode.insertBefore(slinfo, slinfoa);
var addlogo = document.createElement('div');
    addlogo.className = 'data-1688-logo';
    var getbg = document.querySelector('.data-content-tools');
    addlogo.innerHTML = '<a href="https://daima.thfou.com" target="_blank"><img class="thflogo" src="https://daima.thfou.com/img/favicon.jpg"></a>';
    getbg.parentNode.insertBefore(addlogo, getbg);
//插入标识
var addbs = document.createElement('div'); // 新增元素
   addbs.className = 'item';
   addbs.innerHTML = '<p>[&nbsp;<a href="https://daima.thfou.com" target="_blank" style="color: #4184f3">头号代码</a>&nbsp;]</p>';
   $('.data-content-tools').append(addbs);
//获取产品类目
var fgf = " >> ";
var categoryLists1 = iDetailData.registeredData.categoryList[0].name;
var categoryLists2 = iDetailData.registeredData.categoryList[1].name;
var categoryLists3 = iDetailData.registeredData.categoryName;
var categoryList = document.createElement('div'); // 新增元素
   categoryList.className = 'item';
   categoryList.id = 'wp-categorylist';
   var lma = '<p>类目:</p><span>';
   var lmb = '</span>';
   categoryList.innerHTML = lma + categoryLists1 + fgf + categoryLists2 + fgf + categoryLists3 + lmb;
   $('.data-content-tools').append(categoryList);
//获取产品总销量
var modconfig = document.getElementById('mod-detail-dealrecord');
var total = modconfig.getAttribute('data-mod-config');
var arr = total.split(",");
var Obj = arr[6];
var cj = Obj.split(':');
var zcj = cj[1].replace(/"/g, "");
var zcjsl = document.createElement('div'); // 新增元素
   zcjsl.className = 'item';
   zcjsl.id = 'cp-total';
   var zcja = '<p>总成交:</p><span>';
   var zcjb = '</span>';
   var zcjc = '<p>' + '&nbsp;' + iDetailConfig.unit + '</p>';
   zcjsl.innerHTML = zcja + zcj + zcjb + zcjc;
   $('.data-content-tools').append(zcjsl);
//获取产品近30天销量
var thirtydayscj = $('.bargain-number a .value').text();
var thirtydays = document.createElement('div'); // 新增元素
   thirtydays.className = 'item';
   thirtydays.id = 'cp-thirtydays';
   var thirtydaysa = '<p>近30天成交:</p><span>';
   var thirtydaysb = '</span>';
   var thirtydaysc = '<p>' + '&nbsp;' + iDetailConfig.unit + '</p>';
   thirtydays.innerHTML = thirtydaysa + thirtydayscj + thirtydaysb + thirtydaysc;
   $('.data-content-tools').append(thirtydays);
//近30天每天均成交计算
var jcjed = Math.floor(thirtydayscj/30);
var jcj = document.createElement('div'); // 新增元素
   jcj.className = 'item';
   jcj.id = 'cp-jcj';
   var jcja = '<p>近30天每天均成交:</p><span>';
   var jcjb = '</span>';
   var jcjc = '<p>' + '&nbsp;' + iDetailConfig.unit + '</p>';
   jcj.innerHTML = jcja + jcjed + jcjb + jcjc;
   $('.data-content-tools').append(jcj);
//新增收录信息标签
var addtag = document.createElement('div'); // 新增元素
   addtag.className = 'item';
   addtag.id = 'cp-addtag';
   addtag.innerHTML = '<span class="addtag">收录信息<span class="addtag-arrow-r">&nbsp;</span></span>';
   $('.data-slinfo-content').append(addtag);
//获取登录ID
var getloginid = document.createElement('div'); // 新增元素
   getloginid.className = 'item';
   getloginid.id = 'wp-loginid';
   var loginId = iDetailData.registeredData.sellerInf['loginId'];
   var urla = '<p>登录ID:</p><span>';
   var urlb = '</span>';
   getloginid.innerHTML = urla + loginId + urlb;
   $('.data-slinfo-content').append(getloginid);
//获取关键词
var getkeywords = document.createElement('div'); // 新增元素
   getkeywords.className = 'item';
   getkeywords.id = 'offer-keywords';
   var sc = document.getElementsByName("keywords")[0].content;
   var sca = '<p>关键词:</p><span>';
   var scb = '</span>';
   var scc = sc;
   var scd = scc.replace(/,/gm, ",");
   getkeywords.innerHTML = sca + scd + scb;
   $('.data-slinfo-content').append(getkeywords);
//插入直播按钮
var addlive = document.createElement('div'); // 新增元素
   addlive.className = 'btn';
   addlive.id = 'wp-live';
   var livea = 'https://cui.m.1688.com/weex/page/7150.html?spm=a261y.7663282.descBanner.1.42a4319e2l7OAw&__positionId__=live&__pageId__=7150&__weex__=true&loginId=';
   var liveb = loginId;
   var livec = '<a style="color:#fff" target="_blank" href="';
   var lived = '">';
   var livee = '进入直播间';
   var livef = '</a>';
   var liveg = encodeURI(liveb);
   addlive.innerHTML = livee;
   $('.data-slinfo-content').append(addlive);
    document.getElementById('wp-live').innerHTML = livec + livea + liveg + lived + livee + livef;
    },1500); // 延迟1.5秒
})();