@@ -2,7 +2,11 @@ chrome.runtime.onInstalled.addListener(() => {
2
2
const sites = [
3
3
{ id : "PageSpeed" , title : "PageSpeed" } ,
4
4
{ id : "BuiltWith" , title : "BuiltWith" } ,
5
+ { id : "Yellow" , title : "Yellow Lab Tools" } ,
6
+ { id : "InspectWP" , title : "InspectWP" } ,
7
+ { id : "Siteliner" , title : "Siteliner" } ,
5
8
{ id : "Cloudinary" , title : "Image Analysis Tool by Cloudinary" } ,
9
+ { id : "W3C" , title : "W3C Markup Validation Service" } ,
6
10
] ;
7
11
8
12
for ( const site of sites ) {
@@ -20,11 +24,15 @@ chrome.contextMenus.onClicked.addListener((info, tab) => {
20
24
tab . url
21
25
) } `,
22
26
BuiltWith : `https://builtwith.com/?${ encodeURIComponent ( tab . url ) } ` ,
23
- Cloudinary : `https://webspeedtest-api.cloudinary.com/test/run` ,
27
+ Yellow : "https://yellowlab.tools/api/runs" ,
28
+ InspectWP : "https://inspectwp.com/en" ,
29
+ Siteliner : "https://www.siteliner.com/" ,
30
+ Cloudinary : "https://webspeedtest-api.cloudinary.com/test/run" ,
31
+ W3C : `https://validator.w3.org/nu/?doc=${ encodeURIComponent ( tab . url ) } ` ,
24
32
} ;
25
33
26
34
if ( info . menuItemId === "Cloudinary" ) {
27
- async function sendPostRequest ( url ) {
35
+ async function sendPostRequestCloudinary ( url ) {
28
36
try {
29
37
const response = await fetch ( siteUrls . Cloudinary , {
30
38
method : "POST" ,
@@ -47,7 +55,94 @@ chrome.contextMenus.onClicked.addListener((info, tab) => {
47
55
}
48
56
}
49
57
50
- sendPostRequest ( tab . url ) ;
58
+ sendPostRequestCloudinary ( tab . url ) ;
59
+ } else if ( info . menuItemId === "Yellow" ) {
60
+ async function sendPostRequestYellow ( url ) {
61
+ try {
62
+ const request = {
63
+ url : url ,
64
+ waitForResponse : false ,
65
+ screenshot : true ,
66
+ device : "phone" ,
67
+ } ;
68
+
69
+ const response = await fetch ( siteUrls . Yellow , {
70
+ method : "POST" ,
71
+ headers : {
72
+ "Content-Type" : "application/json" ,
73
+ } ,
74
+ body : JSON . stringify ( request ) ,
75
+ } ) ;
76
+
77
+ const data = await response . json ( ) ;
78
+ const runId = data . runId ;
79
+ const runUrl = `https://yellowlab.tools/queue/${ runId } ` ;
80
+
81
+ chrome . tabs . create ( { url : runUrl } ) ;
82
+ } catch ( error ) {
83
+ console . error ( "Erro ao enviar URL para Yellow Lab Tools:" , error ) ;
84
+ }
85
+ }
86
+
87
+ sendPostRequestYellow ( tab . url ) ;
88
+ } else if ( info . menuItemId === "InspectWP" ) {
89
+ try {
90
+ chrome . tabs . query ( { active : true , currentWindow : true } , ( tabs ) => {
91
+ const activeTab = tabs [ 0 ] ;
92
+ const activeTabUrl = activeTab . url ;
93
+
94
+ chrome . tabs . create ( { url : siteUrls . InspectWP } , ( newTab ) => {
95
+ chrome . tabs . onUpdated . addListener ( function onUpdated (
96
+ tabId ,
97
+ changeInfo
98
+ ) {
99
+ if ( tabId === newTab . id && changeInfo . status === "complete" ) {
100
+ chrome . scripting . executeScript ( {
101
+ target : { tabId : newTab . id } ,
102
+ func : ( url ) => {
103
+ document . getElementById (
104
+ "inspectwp-checker-form-url-input"
105
+ ) . value = url ;
106
+ document . querySelector ( "div.input-group button" ) . click ( ) ;
107
+ } ,
108
+ args : [ activeTabUrl ] ,
109
+ } ) ;
110
+ chrome . tabs . onUpdated . removeListener ( onUpdated ) ;
111
+ }
112
+ } ) ;
113
+ } ) ;
114
+ } ) ;
115
+ } catch ( error ) {
116
+ console . error ( "Erro ao enviar URL para InspectWP:" , error ) ;
117
+ }
118
+ } else if ( info . menuItemId === "Siteliner" ) {
119
+ try {
120
+ chrome . tabs . query ( { active : true , currentWindow : true } , ( tabs ) => {
121
+ const activeTab = tabs [ 0 ] ;
122
+ const activeTabUrl = activeTab . url ;
123
+
124
+ chrome . tabs . create ( { url : siteUrls . Siteliner } , ( newTab ) => {
125
+ chrome . tabs . onUpdated . addListener ( function onUpdated (
126
+ tabId ,
127
+ changeInfo
128
+ ) {
129
+ if ( tabId === newTab . id && changeInfo . status === "complete" ) {
130
+ chrome . scripting . executeScript ( {
131
+ target : { tabId : newTab . id } ,
132
+ func : ( url ) => {
133
+ document . getElementById ( "field-domain" ) . value = url ;
134
+ document . getElementById ( "button-check-new" ) . click ( ) ;
135
+ } ,
136
+ args : [ activeTabUrl ] ,
137
+ } ) ;
138
+ chrome . tabs . onUpdated . removeListener ( onUpdated ) ;
139
+ }
140
+ } ) ;
141
+ } ) ;
142
+ } ) ;
143
+ } catch ( error ) {
144
+ console . error ( "Erro ao enviar URL para Siteliner:" , error ) ;
145
+ }
51
146
} else if ( siteUrls [ info . menuItemId ] ) {
52
147
chrome . tabs . create ( { url : siteUrls [ info . menuItemId ] } ) ;
53
148
}
0 commit comments