您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Copie la description de l'article lorsque une url appropriée est présente dans le presse papier
当前为
// ==UserScript== // @name [HFR] SFBA descriptor // @namespace forum.hardware.fr // @version 0.1 // @description Copie la description de l'article lorsque une url appropriée est présente dans le presse papier // @author You // @include http://forum.hardware.fr/message.php* // @include http://forum.hardware.fr/forum2.php* // @include http://forum.hardware.fr/hfr/* // @connect * // @grant GM_info // @grant GM_deleteValue // @grant GM_getValue // @grant GM_listValues // @grant GM_setValue // @grant GM_getResourceText // @grant GM_getResourceURL // @grant GM_addStyle // @grant GM_log // @grant GM_openInTab // @grant GM_registerMenuCommand // @grant GM_setClipboard // @grant GM_xmlhttpRequest // @require http://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js // ==/UserScript== function init_throbber(){ GM_addStyle("#hiu_throbber{position:fixed;left:0;top:0;background-color:#242424;z-index:1001;" + "display:none;opacity:0;transition:opacity 0.7s ease 0s;}"); GM_addStyle("#hiu_throbber_img{position:fixed;left:calc(50% - 64px);top:calc(50% - 64px);width:128px;height:128px;z-index:1002;" + "display:none;opacity:0;transition:opacity 0.7s ease 0s;border:0;padding:0;}"); GM_addStyle(".hfr_apercu_nope{display:none !important;}"); var throbber_image_url = "http://reho.st/self/30271dc1b7cac925aeabb89fa70e1e17cf5e1840.png"; var hiu_throbber_img = new Image(); hiu_throbber_img.src = throbber_image_url; hiu_throbber_img.setAttribute("id", "hiu_throbber_img"); var hiu_throbber = document.createElement("div"); hiu_throbber.setAttribute("id", "hiu_throbber"); hiu_throbber.appendChild(hiu_throbber_img); hiu_throbber.addEventListener("transitionend", throbber_transitionend, false); document.body.appendChild(hiu_throbber); } function display_throbber(){ if(document.querySelector("div#apercu_reponse")){ document.querySelector("div#apercu_reponse").classList.add("hfr_apercu_nope"); } hiu_throbber_img.style.display = "block"; hiu_throbber.style.display = "block"; hiu_throbber.style.width = document.documentElement.scrollWidth + "px"; hiu_throbber.style.height = document.documentElement.scrollHeight + "px"; hiu_throbber_img.style.opacity = "1"; hiu_throbber.style.opacity = "0.8"; } function throbber_transitionend() { if(hiu_throbber.style.opacity === "0") { hiu_throbber_img.style.display = "none"; hiu_throbber.style.display = "none"; if(document.querySelector("div#apercu_reponse")){ document.querySelector("div#apercu_reponse").classList.remove("hfr_apercu_nope"); } } } function hide_throbber(){ hiu_throbber_img.style.opacity = "0"; hiu_throbber.style.opacity = "0"; } function insert_text_at_cursor (textarea, text) { var start = textarea.selectionStart; var end = textarea.selectionEnd; textarea.value = textarea.value.substr (0, start) + text + textarea.value.substr (end); textarea.setSelectionRange (start + text.length, start + text.length); } function isUrlValid(url) { return /^(https?|s?ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(url); } function isUrlParsable(url) { if (url.indexOf("amazon") !== -1) { return true; } else if (url.indexOf("aliexpress") !== -1) { return true; } else { return false; } } function parseAmazon(doc) { var img = ""; var title = doc.find("#productTitle").text().trim(); var imgJson = doc.find("#imgTagWrapperId").children().attr('data-a-dynamic-image'); if (imgJson) img = Object.keys(JSON.parse(imgJson))[0]; var price = doc.find(".a-size-medium.a-color-price").eq(0).text().trim(); if (title && img && price) return title + " - " + price + "[/url]\n[img]http://reho.st/" + img + "[/img]"; else return ""; } function parseAli(doc) { var title = doc.find(".product-name").text().trim(); var img = doc.find(".ui-image-viewer-thumb-frame").children().attr('src'); var price = doc.find("#j-sku-price").text().trim(); if (title && img && price) return title + " - " + price + "[/url]\n[img]http://reho.st/" + img + "[/img]"; else return ""; } init_throbber(); function pasting (event) { var url = ""; var bbcode = ""; if (event.clipboardData.files.length < 1) { var str = event.clipboardData.getData("text/plain"); if ( (str.length === 0) && (!isUrlValid(str)) && (!isUrlParsable(str)) ) return; else url = str; } // chargement display_throbber(); GM_xmlhttpRequest({ method : "GET", url : url, context : { textarea : this }, onabort : hide_throbber, onerror : hide_throbber, ontimeout : hide_throbber, onload : function (response) { // fin du chargement hide_throbber(); if (url.indexOf("amazon") !== -1) { bbcode = parseAmazon($(response.responseText)); } else if (url.indexOf("aliexpress") !== -1) { bbcode = parseAli($(response.responseText)); } if (bbcode) insert_text_at_cursor(this.context.textarea, "[url=" + url + "]" + bbcode); else insert_text_at_cursor(this.context.textarea, "[url]" + url + "[/url]"); } }); return event.preventDefault(); } var content_form = document.querySelector("#content_form"); if (content_form !== null) content_form.addEventListener('paste', pasting); var observer=new MutationObserver(function(mutations, observer){ var textareas=document.querySelectorAll("textarea[id^=\"rep_editin_\"]" ); if(textareas.length){ for(var textarea of textareas) { textarea.removeEventListener('paste', pasting, false); textarea.addEventListener('paste', pasting, false); } } }); observer.observe(document, {attributes: false, childList: true, characterData: false, subtree: true});
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址