// ==UserScript== // @name 知乎-匿名提问者标注 // @namespace http://tampermonkey.net/ // @version 0.1 // @description 在问题页, 标注匿名提问, 防止钓鱼 // @author C4r // @match https://www.zhihu.com/* // @require https://cdn.jsdelivr.net/npm/jquery@3.5.0/dist/jquery.min.js // @grant none // @downloadURL none // ==/UserScript== (function() { 'use strict'; function isHome(){ return $("#TopstoryContent").length > 0 } function isQuestionPage(){ return $('.QuestionPage').length > 0 } function getLogURL(questionURL){ // return new URL('log', questionURL).href return questionURL + '/log' } function httpGetAsync(theUrl, callback) { var xmlHttp = new XMLHttpRequest(); xmlHttp.onreadystatechange = function () { if (xmlHttp.readyState == 4 && xmlHttp.status == 200) callback(xmlHttp.responseText); } xmlHttp.open("GET", theUrl, true); // true for asynchronous xmlHttp.send(null); } function getAuthorUrl(logURL){ return new Promise((resolve, reject) => { httpGetAsync(logURL, (responseText) => { // console.log('get response') let repHTML = $.parseHTML(responseText) let author = $(repHTML).find('.zm-item:last > div > a').attr('href') if(author != undefined){ let userInfo = { 'name': $(repHTML).find('.zm-item:last > div > a').text(), 'url': $(repHTML).find('.zm-item:last > div > a').get(0).href, 'a': $(repHTML).find('.zm-item:last > div > a').get(0).outerHTML } resolve(userInfo) }else{ // console.log( '匿名提问 : ', undefined) resolve(undefined) } }) }) } function topic(){ return '\