首页
关于
Search
1
git lg彩色显示日志
29 阅读
2
在 Ubuntu 22.04 LTS 中安装 Docker
19 阅读
3
CentOs/Ubuntu搭建上网x-ui
18 阅读
4
git使用多个源和多个分支
15 阅读
5
git保存账号密码
15 阅读
默认分类
网站搭建
Windows
Linux
Docker
OpenWrt
Hackintosh
Git
Python
Web开发
JavaScript
FFmpeg
Demo
工具
刷机
油猴脚本
Excel
Chrome Extension
登录
Search
标签搜索
Pandas
读取
时区
Chrome
centos8
求和
Nginx
Typecho
404
csv
国际站
询盘导出
油猴脚本
bbr
Ubuntu
远程桌面
日志
log
数据清洗
打印机
野生程序猿
累计撰写
155
篇文章
累计收到
0
条评论
首页
栏目
默认分类
网站搭建
Windows
Linux
Docker
OpenWrt
Hackintosh
Git
Python
Web开发
JavaScript
FFmpeg
Demo
工具
刷机
油猴脚本
Excel
Chrome Extension
页面
关于
搜索到
155
篇与
的结果
2022-07-29
查看 Linux 发行版名称和版本号的 8 种方法
lsb_release 命令 /etc/*-release 文件 uname 命令 /proc/version 文件 dmesg 命令 yum 或 dnf 命令 rpm 命令 apt-get 命令
2022年07月29日
5 阅读
0 评论
0 点赞
2022-07-17
CentOs/Ubuntu搭建上网x-ui
另一个#先更新源 yum update apt update #启用 BBR TCP 拥塞控制算法 echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf sysctl -p #安装x-ui: bash <(curl -Ls https://raw.githubusercontent.com/vaxilu/x-ui/master/install.sh) #安装nginx apt install nginx yum install nginx #安装acme: curl https://get.acme.sh | sh #添加软链接: ln -s /root/.acme.sh/acme.sh /usr/local/bin/acme.sh #切换CA机构: acme.sh --set-default-ca --server letsencrypt #申请证书: acme.sh --issue -d 要替换的域名 -k ec-256 --webroot /var/www/html #安装证书: acme.sh --install-cert -d 要替换的域名 --ecc \ --key-file /etc/x-ui/server.key \ --fullchain-file /etc/x-ui/server.crt \ --reloadcmd "systemctl force-reload nginx"寻找适合的伪装站http站点优先,个人网盘符合单节点大流量特征示例关键字: intext:登录 Cloudreve 配置nginx配置文件路径:/etc/nginx/nginx.conf# user www-data; #ubuntu下好像用这个 user nginx; worker_processes auto; pid /run/nginx.pid; include /etc/nginx/modules-enabled/*.conf; events { worker_connections 1024; } http { sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; gzip on; server { listen 443 ssl; server_name ui.你的域名.shop; #你的域名 ssl_certificate /etc/x-ui/server.crt; #证书位置 ssl_certificate_key /etc/x-ui/server.key; #私钥位置 ssl_session_timeout 1d; ssl_session_cache shared:MozSSL:10m; ssl_session_tickets off; ssl_protocols TLSv1.2 TLSv1.3; ssl_prefer_server_ciphers off; location / { proxy_pass http://cloudreve.lee2333.com/; #伪装网址 proxy_redirect off; proxy_ssl_server_name on; sub_filter_once off; sub_filter "cloudreve.lee2333.com" $server_name; proxy_set_header Host "cloudreve.lee2333.com"; proxy_set_header Referer $http_referer; proxy_set_header X-Real-IP $remote_addr; proxy_set_header User-Agent $http_user_agent; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto https; proxy_set_header Accept-Encoding ""; proxy_set_header Accept-Language "zh-CN"; } location /4a872606-be19-path-replace { #分流路径 proxy_redirect off; proxy_pass http://127.0.0.1:47403; #Xray端口 proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location /4a872606-be19-path-replace-xui { #xui路径 proxy_redirect off; proxy_pass http://127.0.0.1:65432; #xui监听端口 proxy_http_version 1.1; proxy_set_header Host $host; } } server { listen 80; location /.well-known/ { #root /var/www/html;#Ubuntu root /usr/share/nginx/html;#centos } location / { rewrite ^(.*)$ https://$host$1 permanent; } } }x-ui创建节点时选择监听127.0.0.1重新加载nginx nginx -s reload 更新证书acme.sh --issue -d xxx.xxx.com -k ec-256 --webroot /usr/share/nginx/html --force acme.sh --install-cert -d xxx.xxx.com --ecc --key-file /etc/x-ui/server.key --fullchain-file /etc/x-ui/server.crt --reloadcmd "nginx -s reload" #xxx.xxx.com替换为域名宝塔面板nginx设置方法1.新建域名站点,申请SSL证书2.启用WordPress伪静态3.配置nginx # 入站配置 location /07f7f { proxy_redirect off; proxy_pass http://127.0.0.1:12354; #Xray端口 proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } # x-ui面板 location ^~ /07f7f-xui { proxy_redirect off; proxy_pass http://127.0.0.1:65432/07f7f-xui; #xui监听端口 proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; }4.修改x-ui面板监听地址为127.0.0.1(防止端口直接被访问)修改面板路径/07f7f-xui/5.重启面板生效
2022年07月17日
18 阅读
0 评论
0 点赞
2022-07-17
卸载宝塔面板后yum无法安装nginx
找到这个文件:/etc/yum.conf ,将 exclude 这一行注释掉就行了。[main] gpgcheck=1 installonly_limit=3 clean_requirements_on_remove=True best=True exclude=httpd nginx php mysql mairadb python-psutil python2-psutil
2022年07月17日
2 阅读
0 评论
0 点赞
2022-07-15
Python输出日志logging
代码1:在控制台输出log日志import logging logging.basicConfig(level=logging.WARNING, format='%(asctime)s - %(filename)s[line:%(lineno)d] - %(levelname)s: %(message)s') # 开始使用log功能 logging.info('这是 loggging info message') logging.debug('这是 loggging debug message') logging.warning('这是 loggging a warning message') logging.error('这是 an loggging error message') logging.critical('这是 loggging critical message')代码2:在文件中写入log日志import logging logging.basicConfig(level=logging.WARNING, filename='./log.txt', filemode='w', format='%(asctime)s - %(filename)s[line:%(lineno)d] - %(levelname)s: %(message)s') # use logging logging.info('这是 loggging info message') logging.debug('这是 loggging debug message') logging.warning('这是 loggging a warning message') logging.error('这是 an loggging error message') logging.critical('这是 loggging critical message')代码3:在控制台和文件中分别输出log日志import logging # 第一步,创建一个logger logger = logging.getLogger() logger.setLevel(logging.INFO) # Log等级总开关 此时是INFO # 第二步,创建一个handler,用于写入日志文件 logfile = './log.txt' fh = logging.FileHandler(logfile, mode='a') # open的打开模式这里可以进行参考 fh.setLevel(logging.DEBUG) # 输出到file的log等级的开关 # 第三步,再创建一个handler,用于输出到控制台 ch = logging.StreamHandler() ch.setLevel(logging.WARNING) # 输出到console的log等级的开关 # 第四步,定义handler的输出格式(时间,文件,行数,错误级别,错误提示) formatter = logging.Formatter("%(asctime)s - %(filename)s[line:%(lineno)d] - %(levelname)s: %(message)s") fh.setFormatter(formatter) ch.setFormatter(formatter) # 第五步,将logger添加到handler里面 logger.addHandler(fh) logger.addHandler(ch) # 日志级别 logger.debug('这是 logger debug message') logger.info('这是 logger info message') logger.warning('这是 logger warning message') logger.error('这是 logger error message') logger.critical('这是 logger critical message') # # DEBUG:详细的信息,通常只出现在诊断问题上 # INFO:确认一切按预期运行 # WARNING(默认):一个迹象表明,一些意想不到的事情发生了,或表明一些问题在不久的将来(例如。磁盘空间低”)。这个软件还能按预期工作。 # ERROR:更严重的问题,软件没能执行一些功能 # CRITICAL:一个严重的错误,这表明程序本身可能无法继续运行代码4:log文件大小设置配置文件大小及数量,比如:“设置写入文件,如果文件超过1M大小时,切割日志文件,仅保留3个文件”若文件大小超过1M大小时,就切割日志文件,仅保留3个文件,并且文件的格式为app.log1、app.log2...from logging.handlers import RotatingFileHandler logger_handler = RotatingFileHandler(filename=log_path, maxBytes=1 * 1024 * 1024, backupCount=3, encoding='utf-8')
2022年07月15日
1 阅读
0 评论
0 点赞
2022-07-11
阿里巴巴国际站产品辅助脚本
// ==UserScript== // @name 阿里巴巴国际站产品辅助脚本 // @namespace http://www.alibaba.com // @author Lepturus // @version 0.0.9 // @icon http://is.alicdn.com/favicon.ico // @description 1. 添加【零效果产品页】【产品运营工作台页】【产品分析页】编辑及数据效果查看按钮 2. 添加【产品详情页】编辑及数据查看按钮,修改图片链接为原图,添加显示产品关键词,添加视频链接与封面链接 3. 添加【图片银行页】直接下载原图按钮 4. 添加【关键词指数页】搜索按钮 5. 添加【产品关键词搜索页】显示公司名按钮 6.添加【产品列表页】序列和效果按钮 7. 显示阿里巴巴标签页名称 8. 【产品编辑页】增强 // @match *://www.alibaba.com/* // @match *://data.alibaba.com/* // @match *://*.alibaba.com/trade/search* // @match *://*.alibaba.com/product-detail/* // @match *://keywordIndex.alibaba.com/* // @match *://photobank.alibaba.com/* // @match *://post.alibaba.com/* // @match *://hz-productposting.alibaba.com/* // @match *.alibaba.com/product/* // @grant GM_addStyle // @license MIT // ==/UserScript== ////********************************************** //// 1. 添加【产品运营工作台页】产品编辑及查看产品效果按钮 //// 2. 添加【产品分析页】含【零效果产品页】页 编辑及查看产品分层按钮 //// 3. 添加【产品详情页】编辑查看产品效果按钮,修改图片链接为原图,添加显示产品关键词(点击关键词可复制),添加视频链接与封面链接 //// 4. 添加【图片银行页】直接下载原图按钮 //// 5. 添加【关键词指数页】内 【关键词分析】搜索按钮 //// 6. 添加【产品关键词搜索页】显示公司名按钮,若出现供应商名称顺序对不上的情况,一般重新刷新页面可正确显示,或者重新刷新页面后使用强制显示供应商名称模式(注意先开启该按钮再开启左边ON/OFF按钮) //// 7. 添加【产品列表页】序列(点击可复制询盘链接)和产品效果按钮 //// 8. 显示阿里巴巴标签页名称 //// 9. 【产品编辑页】增强, 添加关键词直接搜索按钮,添加导航快捷按钮(上传图片 质量分检测【当阿里质量分按钮不存在时也可检测】 提交产品),辅助添加标题单词首字母转大写功能 ////********************************************** (function () { 'use strict'; GM_addStyle( ".switch{position:relative;width:45px;height:17px;display:inline-block} .switch input{display:none}.d_slider{position:absolute;cursor:pointer;top:0;left:0;right:0;bottom:0;background-color:#ca2222;transition:.4s}.d_slider:before{position:absolute;content:'';height:13px;width:13px;left:2px;bottom:2px;background-color:#fff;transition:.4s}input:checked+.d_slider{background-color:#2ab934}input:checked+.d_slider:before{transform:translateX(28px)}.on{display:none}.off,.on{color:#fff;position:absolute;transform:translate(-50%,-50%);top:50%;left:50%;font-size:8px}input:checked+.d_slider .on{display:block} input:checked+.d_slider .off{display:none}.d_slider.round{border-radius:17px}.d_slider.round:before{border-radius:50%}" ); // 工具函数 -- 添加元素属性 function setAttributes(el, attrs) { for (let key in attrs) { el.setAttribute(key, attrs[key]); } } // 工具函数 -- 复制 function copy(e, textContent = true) { let obj = document.createElement('input'); document.body.appendChild(obj); obj.value = textContent ? e.textContent : e; obj.select(); document.execCommand('copy', false); obj.remove(); return obj.value } // 工具函数 -- 序数 function addCounter(productList, margin) { var cssText = "position:absolute;z-index:1;margin-left:" + margin + "px;display:inline-block;background:SlateGray;color:WhiteSmoke;font-family:'微软雅黑';font-size:14px;text-align:center;width:20px;line-height:20px;border-radius:50%;"; var div = document.createElement('div'); var idx = 1; for (var i = 0; i < productList.length; i++) { if (productList[i].getAttribute('data-index')) { continue; } else { productList[i].setAttribute('data-index', idx); div.innerHTML = "<div id='product_" + i + "' style=" + cssText + ">" + idx + "</div>"; productList[i].innerHTML = div.innerHTML + productList[i].innerHTML; idx++; } } } // 工具函数 -- 首字母大写 function Capitalize(str) { return str.replace(/\w\S*/g, function (txt) { return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); }); } function productList() { if (document.querySelector(".product-info")) { addCounter(document.querySelectorAll(".product-info"), -80); } let productList = document.querySelectorAll(".product-info"); for (var i = 0; i < productList.length; i++) { var el = document.getElementsByClassName('product-id')[i]; var el2 = document.getElementById("product_" + i); var product_id = el.innerText.replace(/[^0-9]/ig, ""); let inquiry_url = "https://message.alibaba.com/msgsend/contact.htm?action=contact_action&domain=1&id=" + product_id; var similar_url = "https://post.alibaba.com/product/publish.htm?pubType=similarPost&itemId=" + product_id; el2.onclick = function () { copy(inquiry_url, false) alert(`${inquiry_url}\n……Copy The Inquiry URL Done……`); } el.setAttribute('data-href', inquiry_url) let product_a = productList[i].parentNode.querySelector(".next-col.next-col-3>span>div") if (product_a){ let product_analysis = document.createElement("span"); product_analysis.innerHTML = `<br><a href="https://data.alibaba.com/product/overview?prodId=${product_id}" target="_blank">效果</a>`; if (!product_a.textContent.match("效果")) { // 动态加载fix product_a.appendChild(product_analysis); } } } } // 添加产品运营工作台产品编辑按钮 function productEdit() { let products, products_cell; if (document.querySelector('.upgrade-products-article-item')) { products_cell = '.upgrade-products-article-item'; products = document.querySelectorAll(products_cell); } else { products_cell = '.upgrade-products-grid-record'; products = document.querySelectorAll(products_cell); } let ln = products.length; // 非已经存在编辑按钮 if (ln && !document.querySelector(products_cell).textContent.match("编辑")) { for (let i = 0; i < ln; i++) { let product_title = products[i].querySelector(".product-subject").title; let product_container = products[i].querySelector(".product-id"); let product_id = product_container.textContent.match(/\d+/)[0]; // 产品ID // console.log(product_title, product_id); let product_href = `<a href="//post.alibaba.com/product/publish.htm?spm=a2747.manage.0.0.77fb71d2zK7Jvr&itemId=${product_id}" target="_blank"><br/>编辑</a> <a href="//hz-productposting.alibaba.com/product/manage_products.htm?#/product/all/1-10/productId=${product_id}" target="_blank"> 数据</a> <a href="https://data.alibaba.com/product/overview?prodId=${product_id}" target="_blank">效果明细</a>` if (!product_container.textContent.match("编辑")) { // 动态加载fix product_container.innerHTML += product_href; } } console.log("添加产品运营工作台产品编辑按钮成功!!!"); } } // 添加产品分析页面按钮 function productAnalyse() { let product_tab = document.querySelector(".Product_tab .next-tabs-nav li[aria-selected='true']").textContent let products = document.querySelectorAll('tbody>tr') let ln = products.length; // 非已经存在产品分层按钮 if (product_tab =="我的产品"){ if (ln && !document.querySelector('tbody>tr:last-child').textContent.match("分层")) { for (let i = 0; i < ln; i++) { let product_title = products[i].querySelector(".media-content").textContent; let product_url = products[i].querySelector(".custom-td-content>a").href; let product_id = product_url.match(/_(\d+)\.htm(l)?/)[1]; // 产品ID // console.log(product_title, product_id); let product_newURL = "https://post.alibaba.com/product/publish.htm?spm=a2747.manage.0.0.8e9071d2H60Rr7&pubType=similarPost&itemId=" + product_id + "&behavior=copyNew"; let product_href = `<br><a class="action-enabled TEST" href="${product_newURL}" target="_blank" behavior="copyToNewProduct">复制</a><br> <a class="action-enabled TEST" href="//hz-productposting.alibaba.com/product/manage_products.htm?#/product/all/1-10/productId=${product_id}" target="_blank">分层</a>`; // 非产品不可编辑状态 if (products[i].querySelector(".action-enabled")) { let product_container = products[i].querySelector(".action-enabled").parentElement; // 插入span 编辑 ... if (!product_container.textContent.match("分层")) { // fix动态加载js,指选择日期产品后排序会重复添加的 product_container.innerHTML += product_href; } } // product_container.parentNode.insertBefore(document.createElement("br"), product_container.nextSibling); // document.querySelector('col:last-child').style.setProperty("width", "180px", "important"); // 设置表格最后一栏宽度 } console.log("添加产品分析页面按钮成功!!!"); }} else{ // 零效果产品 // 非对不起,未能查询到符合您要求的产品,建议重新设置查询条件或者已经存在复制按钮 if (!document.querySelector('.ineffective-product tbody>tr').textContent.match("未能查询到") && !document.querySelector('.ineffective-product tbody>tr').textContent .match("复制")) { products = document.querySelectorAll('.ineffective-product tbody>tr') ln = products.length; for (let i = 0; i < ln; i++) { let product_info = products[i].querySelectorAll('.next-table-cell-wrapper'); // 表格每一行产品 // console.log(product_info); let product_url = product_info[1].querySelector("a").href; let product_container = product_info[6].querySelector(".edit-delete-off"); // <span class="edit-delete-off">... let product_id = product_url.match(/_(\d+)\.htm(l)?/)[1]; // http://www.alibaba.com/product-detail//XXX_123456789.html?spm=a2... // 产品ID let product_newURL = "https://post.alibaba.com/product/publish.htm?spm=a2747.manage.0.0.8e9071d2H60Rr7&pubType=similarPost&itemId=" + product_id + "&behavior=copyNew"; let product_HTML = document.createElement("span"); product_HTML.innerHTML = `<a href="${product_newURL}" target="_blank" behavior="copyToNewProduct">复制</a><br/> <a href="//hz-productposting.alibaba.com/product/manage_products.htm?#/product/all/1-10/productId=${product_id}" target="_blank">数据</a><span> </span> <a href="https://data.alibaba.com/product/overview?prodId=${product_id}" target="_blank">效果</a>`; if (!product_container.textContent.match("数据")) { // 动态加载fix product_container.appendChild(product_HTML); } } console.log("零效果产品页复制按钮添加成功!!!"); } } } // 添加产品页按钮 function productDetail() { let product_id; if (!document.querySelector('.ali_product_keywords')) { if (document.querySelector(".module-pdp-title") || document.querySelector(".product-title")) { let product_title; let product_title_container; let product_image_container; if (document.querySelector(".module-pdp-title")){ product_title = document.querySelector(".module-pdp-title").textContent; product_title_container = ".module-pdp-title"; product_image_container = ".main-image-thumb-item img"; } else{ product_title = document.querySelector(".product-title h1").textContent; product_title_container = ".product-title h1"; product_image_container = ".main-list>.main-item>img"; } // 在不同浏览器或设备显示代码不一样 // console.log(product_title); if (/\/product\//.test(document.URL)) { product_id = document.URL.match(/(\d+)-(\d+)/)[1];; // 产品ID } else if (/chinese\.alibaba/.test(document.URL)) { product_id = document.URL.match(/-(\d+)\.htm(l)?/)[1]; // 中文网页产品ID } else { product_id = document.URL.match(/_(\d+)\.htm(l)?/)[1]; // 产品ID } // 产品标题 - Buy () on Alibaba.com let product_keywords = document.title.match(/- Buy (.*) Product/)[1]; // 产品关键词 let product_keywords_html = product_keywords.split(",").map(item => ( `<br/><i class="next-icon next-icon-success next-icon-xs" style="margin-right:5px;"></i><span class="product_keyword">${item}</span>` )).join(""); // overwriting the innerHTML is not a good idea indeed, will gone event listener so using appendChild here. let product_html = document.createElement("div"); product_html.innerHTML = `<p style="color:#ff6a00" class="ali_product_keywords">${product_keywords_html}</p>`; document.querySelector(product_title_container).parentElement.appendChild(product_html); // 同标题class let kws = document.getElementsByClassName("product_keyword"); for (let i = 0; i < kws.length; i++) { kws[i].onclick = function () { let kkws = copy(kws[i]); kws[i].innerHTML = "Copied"; window.setTimeout(function () { kws[i].innerHTML = kkws; }, 1500) } } console.log("添加产品分析页面按钮成功!!!"); document.querySelectorAll(product_image_container).forEach(v => (v.src = v.src.replace( /_50x50\.(jpg|png)/, "").replace(/_100x100xz\.(jpg|png)/, ""))); // 修改图片轮播链接为原图 } } // 动态加载 window.addEventListener('load', function () { if (document.querySelector(".details-user-actions")) { let container = document.querySelector(".details-user-actions"); let product_tool = document.createElement("span"); if (document.querySelector('.image-d_slider video')) { if (!document.querySelector('.details-user-actions').textContent.match("视频")) { let video_link = document.querySelector('video').src; // 产品视频链接 let video_poster = document.querySelector('video').poster; // 产品视频封面链接 let video_html = `<a href="${video_link}" target="_blank">视频链接 </a><a href="${video_poster}" target="_blank">视频封面</a>` product_tool.innerHTML = video_html; } } let product_edit_style = document.querySelector(".is-magic") ? "智能编辑" : document.querySelector( "#J-rich-text-description>div:only-child") ? "旧版智能编辑" : "普通编辑"; product_tool.innerHTML += `<br/>${product_edit_style} <a href="//post.alibaba.com/product/publish.htm?spm=a2747.manage.0.0.77fb71d2zK7Jvr&itemId=${product_id}" target="_blank">编辑</a> <a href="//hz-productposting.alibaba.com/product/manage_products.htm?#/product/all/1-10/productId=${product_id}" target="_blank">数据</a> <a href="https://data.alibaba.com/product/overview?prodId=${product_id}" target="_blank">效果明细</a> <a href="https://post.alibaba.com/product/publish.htm?spm=a2747.manage.0.0.8e9071d2H60Rr7&pubType=similarPost&itemId=${product_id}" target="_blank" behavior="copyToNewProduct">复制</a>`; if (!document.querySelector('.details-user-actions').textContent.match("数据")) { container.appendChild(product_tool); } } }) } // 添加图片银行直接下载原图按钮 function productPhoto() { let products = document.querySelectorAll('.photo-grid-item') // 获取图片容器 let ln = products.length; // 非已存在下载原图链接按钮 if (!document.querySelector('.image-info').textContent.match("下载原图")) { for (let i = 0; i < ln; i++) { let product_src = products[i].querySelector(".photo-grid-img-wrapper img").src; // 获取图片链接 let product_picforamt = product_src.match(/_350x350\.(jpg|png)/)[1]; let product_picLink = product_src.replace(/_350x350\.(jpg|png)/, ""); let product_picName = products[i].querySelector(".display-name button").textContent; // 获取图片文件名 // console.log(product_picName); let product_picContainer = products[i].querySelector(".image-info"); let product_picHTML = document.createElement("a"); setAttributes(product_picHTML, { "href": `${product_picLink}?attachment=${product_picName}.${product_picforamt}`, "target": "_blank", "rel": "noopener noreferrer" }); product_picHTML.innerHTML = "下载原图"; product_picContainer.appendChild(product_picHTML); } // console.log("添加图片银行直接下载原图按钮成功!"); } } //添加关键词指数页搜索按钮 function productKeywordIndex() { let keywords = document.querySelectorAll('.next-table-row'); let ln = keywords.length; // 非已经存在搜索按钮 if (ln && !document.querySelector('.next-table-row a i')) { for (let i = 0; i < ln; i++) { let kws_container = keywords[i].querySelectorAll(".next-table-cell-wrapper")[1].querySelector( "span"); let kw = kws_container.querySelector("a").textContent; let alibaba_link = document.createElement("a"); setAttributes(alibaba_link, { "href": `https://www.alibaba.com/products/${kw}.html?viewtype=G`, "target": "_blank", "rel": "noopener noreferrer", "title": "在阿里巴巴搜索" }); alibaba_link.innerHTML = ` <i class="next-icon next-icon-search next-small next-search-icon"></i>`; let product_link = document.createElement("a"); setAttributes(product_link, { "href": `https://hz-productposting.alibaba.com/product/manage_products.htm?#/product/all/1-10/productKeyword=${kw}`, "target": "_blank", "rel": "noopener noreferrer", "title": "在发布产品列表搜索" }); product_link.innerHTML = ` <i class="next-icon next-icon-search next-small next-search-icon"></i>`; if (!kws_container.querySelector('.next-table-row a i')) { // 动态加载fix kws_container.appendChild(alibaba_link); kws_container.appendChild(product_link); } } console.log("添加关键词指数页搜索按钮成功!!!"); } } // 产品编辑页增强 function productPublish() { let product_keywords; product_keywords = document.querySelectorAll(".posting-field-keywords li"); function alibaba_link(kw) { let kw_search_link = document.createElement("a"); setAttributes(kw_search_link, { "href": `https://www.alibaba.com/products/${kw}.html?viewtype=G`, "target": "_blank", "rel": "noopener noreferrer", "title": "在阿里巴巴搜索", "class": "alibaba_search", }); kw_search_link.innerHTML = `<i class="next-icon next-icon-search next-small next-search-icon"></i>`; return kw_search_link; } for (let i = 0; i < product_keywords.length; i++) { let kw_container = product_keywords[i].querySelector(".next-input-control"); kw_container.appendChild(alibaba_link(product_keywords[i].querySelector("input").value)); product_keywords[i].querySelector("input").addEventListener('change', function (e) { kw_container.replaceChild(alibaba_link(this.value), kw_container.querySelector( '.alibaba_search')); }); } if (document.querySelectorAll("#productsm").length < 1) { let product_menu = document.querySelector('.next-menu-content') product_menu.insertAdjacentHTML('beforeend', '<li id="productpic" tabindex="-1" role="menuitem" class="next-menu-item next-nav-item"><span>上传图片</span></li>' ); document.querySelector('#productpic').onclick = function () { let img_uploadButton = document.getElementsByClassName('upload-select-inner')[0].getElementsByTagName( "button")[0] if (img_uploadButton.disabled) { alert("产品图片已满,请删除部分图片后重新尝试上传!") } else { img_uploadButton.click(); // document.querySelector('#productpic span').style.color = "orange" } } product_menu.insertAdjacentHTML('beforeend', '<li id = "productsc" tabindex="-1" role="menuitem" class="next-menu-item next-nav-item"><span>检测质量分</span></li' ); document.querySelector('#productsc').onclick = function () { let rate = document.getElementById('struct-pinbar').getElementsByClassName('block-text default')[0]; // 产品质量分 if (rate) { rate.click() } else if (document.getElementById('struct-pinbar').getElementsByClassName('block-text')) { document.getElementById('struct-pinbar').getElementsByClassName('block-text')[0].click(); } else { alert("检测出错!") } let product_score = document.getElementById('struct-pinbar').getElementsByClassName('number'); window.setTimeout(function () { if (product_score.length) { document.querySelector('#productsc span').textContent = `检测质量分(${product_score[0].textContent})`; } }, 2500); let product_title = document.getElementById('productTitle').value; let product_titleCapitalize = document.createElement("span"); product_titleCapitalize.className = "product_titleCapitalize"; product_titleCapitalize.innerHTML = `<br>${Capitalize(product_title)}`; let product_title_container = document.getElementById('productTitle').parentNode.parentNode; product_title_container.appendChild(product_titleCapitalize); product_title_container.replaceChild(product_titleCapitalize, product_title_container.querySelector( '.product_titleCapitalize')); product_titleCapitalize.onclick = function () { copy(product_titleCapitalize); product_titleCapitalize.innerHTML = "<br>Copied"; window.setTimeout(function () { product_titleCapitalize.innerHTML = `<br>${Capitalize(product_title)}`; }, 1500); } } product_menu.insertAdjacentHTML('beforeend', '<li id = "productsm" tabindex="-1" role="menuitem" class="next-menu-item next-nav-item"><span>提交产品</span></li' ); document.querySelector('#productsm').onclick = function () { document.getElementsByClassName("next-btn next-btn-primary next-btn-large step-buttons")[0].click(); // 提交按钮 } } } // 搜索关键词显示公司名 function productSupplierDisplay() { let products; if (document.querySelector('.seb-refine-ctb__viewtype>a').classList.contains('active')) { products = document.querySelectorAll('.app-organic-search__list>div.J-offer-wrapper'); } else { products = document.querySelectorAll('.organic-gallery-offer-outter'); } let ln = products.length; function fireMouseEvents(element, eventNames) { if (element && eventNames && eventNames.length) { for (let index in eventNames) { let eventName = eventNames[index]; if (element.fireEvent) { element.fireEvent('on' + eventName); } else { let eventObject = document.createEvent('MouseEvents'); eventObject.initEvent(eventName, true, false); element.dispatchEvent(eventObject); } } } } let supplier_idx = 0 for (let i = 0; i < ln; i++) { let supplier_container; // 视图切换按钮 if (document.querySelector('.seb-refine-ctb__viewtype>a').classList.contains('active')) { supplier_container = products[i].querySelector(".list-no-v2-decisionsup__row"); } else { supplier_container = products[i].querySelector(".organic-gallery-offer_bottom-align-section"); } if (supplier_container && document.getElementById("d_switch").checked) { if (products[i].querySelector('.gallery-theme-card-default__image-ctn') || products[i].querySelector( '.offer-theme-search')) { continue; // 跳过广告位Discover Now } else { supplier_idx = supplier_idx + 1; if (!products[i].querySelector(".alisupplier_name")) { let product_link = products[i].querySelector('a').href; // 获取产品链接 let product_title = products[i].querySelector('.elements-title-normal').textContent; // 获取产品名 // 控制台输出产品标题 测试使用 //console.log(i, product_title); let product_inq, supplier_link, supplier_id = ""; if (document.querySelector('.seb-refine-ctb__viewtype>a').classList.contains('active')) { product_inq = products[i].querySelector('.contact-supplier-btn').href; supplier_link = products[i].querySelector('.list-no-v2-decisionsup__row>span a').href; fireMouseEvents(products[i].querySelector(".list-no-v2-decisionsup__row>span a"), [ 'mouseover', 'mousedown']); // 触发鼠标显示供应商信息 } else { product_inq = products[i].querySelector('.organic-gallery-offer__bottom-v2 a').href; // 获取产品询盘链接 supplier_link = products[i].querySelector(".organic-gallery-offer__seller-company").href; // 获取供应商链接 fireMouseEvents(products[i].querySelector(".organic-gallery-offer__seller-company"), [ 'mouseover', 'mousedown']); // 触发鼠标显示供应商信息 } if (supplier_link.indexOf(".en.alibaba") != -1) { supplier_id = supplier_link.substring(supplier_link.indexOf("//") + 2, supplier_link.indexOf(".en.alibaba")) } else { supplier_id = ""; } console.log(supplier_link, supplier_id); let link = document.createElement("a"); setAttributes(link, { "href": `${supplier_link}`, "target": "_blank", "class": "alisupplier_name", }); // 采集到弹出供应商信息 if (document.querySelector(".next-overlay-wrapper .supplier-tag-popup__content_href")) { if (!document.getElementById("force_supplier").checked) { ; if (supplier_id) { link.innerHTML = document.querySelector( ".next-overlay-wrapper .supplier-tag-popup__content_href").textContent + "(" + supplier_id + "," + supplier_idx +")"; } else { link.innerHTML = document.querySelector( ".next-overlay-wrapper .supplier-tag-popup__content_href").textContent + "(" + supplier_idx +")"; } supplier_container.appendChild(link); let supplier_opener = document.querySelector(".next-balloon-normal"); supplier_opener.parentNode.removeChild(supplier_opener); } } } } } } } // 显示阿里巴巴标签页名称 window.addEventListener('load', function () { let title_list = [".sc-hd-m-logo-anchor", ".av-change-container-title", ".auth-cent-list-container-title", ".product-task-title-name", ".top-bar-name", ".home-header>.home-header-title", ".rank-header-title", ".next-card-title", ".next-feedback-title", ".freight-template-app-title", ".showcase-zh>.fs22", ".inquiry-list-title", ".common-h1", ".title-wrapper>h1", ".live-manage-management-title>h3", ".home-header-title", ".big-title", "h2.page-title>span", ".next-tabs-tab-inner>div", ".bp2-nav-bar>div", ".component-page-title", ".header-title", ".page-title>h3", ".diagnosis-h3", ".collect-products-list h1", ".CGS_BASIC .page-title", "h2.sub-title", ".title", ".title-text", ".photo-header-title", "h1", ".page-title", ".manage-title", ".ui-header-extend", "h2", "h3"]; for (let i = 0; i < title_list.length; i++) { if (! /(w{3}|i|fundma|onetouch|waimaoquan|activity|alicrm|marketing|siteadmin|customize|offer)\.alibaba\.com/ .test(document.URL)) { if (document.querySelector(title_list[i])) { console.log(title_list[i], document.querySelector(title_list[i])); document.title = document.querySelector(title_list[i]).textContent; break; } } } }, false); if (/product_grow_up_manage/.test(document.URL)) { setInterval(productEdit, 2500); // 添加产品运营工作台产品编辑按钮 } else if (/overview/.test(document.URL)) { setInterval(productAnalyse, 2000); // 添加产品分析页面按钮, 含零效果产品 } else if (/(product-detail)|(\/product\/\d+-\d+)/.test(document.URL)) { setInterval(productDetail, 2500); // 添加产品详情页按钮 } else if (/photobank/.test(document.URL)) { setInterval(productPhoto, 2500); // 添加图片银行直接下载原图按钮 } else if (/keyword/.test(document.URL)) { setInterval(productKeywordIndex, 2500); // 添加关键词指数页搜索按钮 } else if (/hz-productposting\./.test(document.URL)) { setInterval(productList, 2500); // 产品编辑页增强 } else if (/(trade\/search)|(\/products\/)/.test(document.URL)) { // 添加搜索关键词显示公司名按钮 if (document.getElementsByClassName('refine-filters__result-left')) { let dswitch = document.createElement('label'); dswitch.innerHTML = "<input id='d_switch' type='checkbox'><div class='d_slider round'><span class='on'>ON</span><span class='off'>OFF</span></div>"; dswitch.setAttribute('class', 'switch'); document.getElementsByClassName('refine-filters__result-left')[0].appendChild(dswitch); document.getElementsByClassName('refine-filters__result-left')[0].innerHTML += '<input type="checkbox" id="force_supplier" style="margin: .4rem;position:relative;top:-3px"><label for="force_supplier">强制显示供应商名称</label>'; } setInterval(productSupplierDisplay, 2500); } else if (/post\.alibaba/ig.test(document.URL)) { window.addEventListener('load', productPublish(), false); // 产品编辑页增强 } })();
2022年07月11日
3 阅读
0 评论
0 点赞
1
...
27
28
29
...
31