leetcode英文版讨论区

中文区的讨论很少,点击查看英文区的讨论

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name     leetcode英文版讨论区
// @version    0.0.5
// @description  中文区的讨论很少,点击查看英文区的讨论
// @author     1xin
// @require     http://code.jquery.com/jquery-latest.js
// @noframes
// @match    *://leetcode-cn.com/problems/*
// @grant    GM_addStyle
// @grant    GM.getValue
// @grant    GM_openInTab
// @grant    GM_notification
// @namespace https://greasyfork.org/users/183871
// ==/UserScript==

(function() {
    'use strict';
    var addNextButton={
        addButton:function(next_video_url){
            var next_btn_html = '';
            next_btn_html +='<button id="englishbutton" class="btn__r7r7 tools-btn__YErs">';
            next_btn_html +="<h3>";
            next_btn_html +='<font color="red">';
            next_btn_html +='查看英文区(leetcode.com)的讨论'
            next_btn_html +='</font>'
            next_btn_html +="</h3>";
            next_btn_html +='</button>';
            //增加下一个视频按钮
            var ul_tag = $("#app");
            if (ul_tag) {
                ul_tag.append(next_btn_html);
            }
            $("#englishbutton").click(function(){
                GM_openInTab(next_video_url);
            });
        }

    };
    var leetSite = window.location.href;
    var patt1=new RegExp("(?<=https://leetcode-cn.com/problems/)[^/]+");
    var text=patt1.exec(leetSite)
    var url_en="https://leetcode.com/problems/";
    url_en+=text;
    url_en+="/discuss/";
    //alert(url_en);
    addNextButton.addButton(url_en);
    // Your code here...
})();