// ==UserScript== // @name 【伟哥自用】CB站添加recurbate链接按钮 // @namespace http://tampermonkey.net/ // @version 0.12 // @description 给chaturbate的follow的人添加recurbate的超链接按钮 // @author 朱焱伟 // @match https://chaturbate.com/followed-cams/offline/ // @match https://chaturbate.com/followed-cams/offline/?page=* // @match https://chaturbate.com/followed-cams/online/ // @match https://chaturbate.com/followed-cams/online/?page=* // @match https://chaturbate.com/followed-cams/ // @icon https://www.google.com/s2/favicons?sz=64&domain=greasyfork.org // @require https://z.chaoxing.com/js/jquery-3.5.0.min.js // @require https://greasyfork.org/scripts/383527-wait-for-key-elements/code/Wait_for_key_elements.js?version=701631 // @grant none // ==/UserScript== /** * - [fixed] ~~脚本目前的缺点是过几分钟刷新就没了,不过正常应该不会等几分钟。~~ */ waitForKeyElements(".room_list_room",handleEveryRoom); function handleEveryRoom(jNode){ /** * jNode is a jQuery object.jNode.html() * console.log(jNode[0].querySelector('.details>div>a').href); */ var room = jNode[0]; var cb_href = room.querySelector('.details>div>a').href; var recurbate_href = cb2recurbate(cb_href); var btn = createCBbtn("recurbate",recurbate_href); room.querySelector(".details>div.title").appendChild(btn); } function cb2recurbate(cb_url){ /** * eg. 'https://chaturbate.com/xxxkeera/' => * 'https://recurbate.com/performer/xxxkeera/' */ return cb_url.replace("chaturbate.com","recurbate.com\/performer") } function createCBbtn(text,href){ var btn = document.createElement("button"); btn.innerText = text; btn.onclick = ()=>{ window.open(href); }; return btn; } /** * ========= for study purposes only ================= * This script is also a minimal working example for the usage of waitForKeyElements(). * * waitForKeyElements(): * - A utility function, for Greasemonkey scripts,that detects and handles AJAXed content. * - origin: https://gist.githubusercontent.com/BrockA/2625891/raw/9c97aa67ff9c5d56be34a55ad6c18a314e5eb548/waitForKeyElements.js * - other forks: CoeJoder has modified Brock Adams's 'waitForKeyElements' on github, but these functions are not compatibile, do not mistake. * - Usage example: * waitForKeyElements ( * "div.comments" * , commentCallbackFunction * ); * * waitForKeyElements() has four Parameters: * * @selectorTxt, Required: The jQuery selector string that * specifies the desired element(s). * * @actionFunction, Required: The code to run when elements are * found. It is passed a jNode to the matched * element. * * @bWaitOnce, Optional: If false, will continue to scan for * new elements even after the first match is * found. * @iframeSelector Optional: If set, identifies the iframe to * search. */