JavaScript 打开提交页面的所有人物解决方案链接

JavaScript 打开提交页面的所有人物解决方案链接

JavaScript 是一种符合ECMAScript规范的高级解释型编程语言。jQuery是一个旨在简化HTML DOM树遍历和操作的JavaScript库。

示例:

  • 步骤1: 打开任何geeksforgeeks解决方案页面,如打开问题提交页面。通过按F12或通过检查选项打开检查模式。
  • 步骤2: 现在在控制台窗口中复制并粘贴以下javascript代码,然后按Enter键。在2.5秒内,所有解决方案将逐个列出。

示例:

// Array to insert page links 
javascript: var arr = []; 
var i = 1; 
  
// Accessing the dom to find the "View solution" 
// link of each person's solution 
for(i = 1; i <= 30; i++) { 
    var flag = false; 
    if (document.getElementsByClassName("well table whiteBgColor") 
                                    [0].children[0].children[i]) { 
          
        var link = document.getElementsByClassName 
                                    ("well table whiteBgColor") 
        [0].children[0].children[i].lastElementChild.children[0] 
                                    .href.trim().toString(); 
          
        // If ith submission is not there 
        // then break the loop 
        flag = true; 
    } 
      
    if (!flag) { 
        break; 
    } 
      
    arr.push(link); 
} 
  
// Opening multiple tabs with 
// the links in the array 
function open_win() { 
    for(var i = 0; i < arr.length; i++) { 
        console.log(arr[i]); 
        window.open(arr[i]); 
    } 
} 
  
// In 2.5 seconds multiple tabs will get 
// open with the search results links 
setTimeout(function() { 
    open_win(); 
}, 2500);
JavaScript

输出:
JavaScript 打开提交页面的所有人物解决方案链接

注意: 在脚本的第一次运行中,会弹出一个窗口。我们必须允许弹出窗口,因为Chrome想知道我们是否希望使用多个标签页。然后重新运行脚本。

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程

登录

注册