Greasy Fork

阿里巴巴商品关键词获取

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

目前为 2019-11-18 提交的版本。查看 最新版本

// ==UserScript==
// @icon             https://www.thfou.com/img/favicon.png
// @name             阿里巴巴商品关键词获取
// @namespace        https://www.thfou.com/
// @version          1.1.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:-5px 5px -5px 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:5px 15px 5px 0px;padding:0px 5px;border-radius:2px;}.thflogo{width:40px;height:40px;margin:0px auto;border-radius:4px;}.data-1688-logo{width:42px;height:100%;float:left;};";
   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://www.thfou.com" target="_blank"><img class="thflogo" src="https://www.thfou.com/img/favicon.png"></a>';
    getbg.parentNode.insertBefore(addlogo, getbg);
//插入标识
var addbs = document.createElement('div'); // 新增元素
   addbs.className = 'item';
   addbs.innerHTML = '<p>[&nbsp;<a href="https://www.thfou.com" target="_blank" style="color: #4184f3">头号代码</a>&nbsp;]</p>';
   $('.data-content').append(addbs);
//获取登录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秒
})();