Greasy Fork

Greasy Fork is available in English.

阿里巴巴商品关键词获取

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

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

您需要先安装一款用户脚本管理器扩展,例如 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          1.2.0
// @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=".data-1688-keywords{width:100%;height:46px;margin-top:-10px;margin-bottom:5px;background-color:rgb(242, 242, 242);}.data-1688-keywords .item{width:auto;height:46px;float:left;margin:0px 5px 0px 15px;}.data-1688-keywords .item p{display:inline-block;width:auto;height:46px;line-height:46px;}.data-1688-keywords .item > span{display:inline-block;width:auto;height:46px;line-height:46px;color:rgb(255, 42, 0);}.data-content{width:100%;height:46px;margin-top:10px;margin-bottom:5px;background-color:rgb(242, 242, 242);}.data-1688-keywords .data-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;}.thflogo{width:40px;height:40px;margin:3px auto;border-radius:4px;}.data-1688-logo{width:42px;height:100%;float:left;}.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 = 'data-1688-keywords';
    var getclass = document.querySelector('.region-horizontal');
    addbg.innerHTML = '<div class="data-content"></div>';
    getclass.parentNode.insertBefore(addbg, getclass);
var addlogo = document.createElement('div');
    addlogo.className = 'data-1688-logo';
    var getbg = document.querySelector('.data-1688-keywords');
    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').append(addbs);
//获取产品类目
   var categoryLists = $('.widget-custom-container script').eq(2).text();
   var regEx = /\s+/g;
   categoryLists = categoryLists.replace(/[^\u4e00-\u9fa5]/gi,' ')
                  .replace(regEx, ' >> ')
                  .replace(/^(\s| >> )+|(\s| >> )+$/g, '')
                  .replace(/^(\s|>> )+|(\s| >> )+$/g, '')
                  .replace(/^(\s|[\u4e00-\u9fa5])+|(\s|[\u4e00-\u9fa5])+$/g, '')
                  .replace(/^(\s|>> )+|(\s| >> )+$/g, '')
                  .replace(/ >>$/gi, '');
var categoryList = document.createElement('div'); // 新增元素
   categoryList.className = 'item';
   categoryList.id = 'wp-categorylist';
   var lm = $('.ww-inline').attr('href');
   var lma = '<p>类目:</p><span>';
   var lmb = '</span>';
   categoryList.innerHTML = lma + categoryLists + lmb;
   $('.data-content').append(categoryList);
//获取登录ID
var getloginid = document.createElement('div'); // 新增元素
   getloginid.className = 'item';
   getloginid.id = 'wp-loginid';
   var datas = $('.ww-inline').attr('href');
   var url = decodeURI(datas);
   var reg = /.*uid[\s\=]+([^\&]+)\&.*/;
   url = url.replace(reg, "$1");
   var urla = '<p>登录ID:</p><span>';
   var urlb = '</span>';
   getloginid.innerHTML = urla + url + urlb;
   $('.data-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;
   getkeywords.innerHTML = sca + scc + scb;
   $('.data-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 = decodeURI(url);
   var livec = '<a style="color:#fff" target="_blank" href="';
   var lived = '">';
   var livee = '进入直播间';
   var livef = '</a>';
   var liveg = encodeURI(liveb);
   addlive.innerHTML = livee;
   $('.data-content').append(addlive);
    document.getElementById('wp-live').innerHTML = livec + livea + liveg + lived + livee + livef;
    },1500); // 延迟1.5秒
})();