查看完整版本 : fwd from 朋友, gpt4 幫你寫 JS bookmarklet 做野

gigighorge 2023-11-19 14:30

[table=100%][tr][td=1,2]empty 123345[/td][td] [/td][/tr][/table]

[[i] 本帖最後由 gigighorge 於 2023-11-19 14:49 編輯 [/i]]

gigighorge 2023-11-19 14:49

[table=100%][tr][td][b][size=6]Show you my love, 話你知典解gpt4 我覺得有用。[/size][/b]
[b][size=6] [/size][/b]
[table=100%][tr][td]有個website save 低時我要人手 F12, hide floating window.
今日問一問gpt4:
You:
hi, i wanna print from a website, but it got a floating screen, everytime i have to press F12 in chrome, search for it and disable the element. any way to make this faster?
------------------
ChatGPT:
To make the process of removing a floating screen from a website faster and more convenient, you can create a bookmarklet in your browser. A bookmarklet is a small piece of JavaScript code that you can save as a bookmark and execute by clicking on it. Here's how you can create a bookmarklet to quickly remove a specific floating element:
Identify the Element: First, use the Chrome DevTools (F12) to identify the floating element. You need to find a unique identifier for it, like an ID or a specific class.
Create the JavaScript Code: Write a small JavaScript snippet that targets and removes or hides the floating element. For example, if the element has an ID of floatingElement, your code might look like this:
javascript
Copy code
document.getElementById('floatingElement').style.display = 'none';
If it's a class, you might use:
javascript
Copy code
document.querySelectorAll('.floatingElementClass').forEach(el => el.style.display = 'none');
Create the Bookmarklet: To turn this into a bookmarklet, you need to create a bookmark with the JavaScript code. Right-click on your bookmarks bar in Chrome and select "Add page...". In the URL field, enter your code like this:
javascript
Copy code
javascript:(function(){ document.getElementById('floatingElement').style.display = 'none'; })();
Make sure it's all in one line and prefixed with javascript:. Give it a name that you'll remember.
Use the Bookmarklet: Now, whenever you visit the website and the floating screen appears, you can simply click on the bookmarklet to remove it.
Remember that bookmarklets are a form of JavaScript execution in the context of the current page, so they should be used carefully. Also, this method requires that the floating element's identifier (ID or class) remains consistent across your visits to the site. If the website frequently changes these identifiers, the bookmarklet might need updating.
------------------
You:
the element is like this:
[b][size=4]Print Options[/size][/b]
[url=#]
      Print
    [/url] | [url=#]Back[/url]
Text
References
Graphics
Contributor Disclosures

------------------
ChatGPT:
Based on the HTML structure you provided, the floating element can be targeted using its ID printControls. You can create a bookmarklet to hide this element. Here's how you can do it:
Write the JavaScript Code: Since the element has an ID of printControls, the JavaScript code to hide this element would be:
javascript
Copy code
document.getElementById('printControls').style.display = 'none';
Create the Bookmarklet: To create the bookmarklet, you need to add this JavaScript code to a bookmark. Here’s how you can do it in Chrome:
Right-click on the bookmarks bar in Chrome and select "Add page...".
In the Name field, enter a descriptive name like “Hide Print Controls”.
In the URL field, enter the JavaScript code in a bookmarklet format. It should look like this:
javascript
Copy code
javascript:(function(){ document.getElementById('printControls').style.display = 'none'; })();
Make sure to include javascript: at the beginning and enclose the code in an immediately invoked function expression (function(){ ... })();.
Use the Bookmarklet: Once the bookmarklet is created, you can simply click on it whenever you are on the page with the floating screen. This will execute the JavaScript code and hide the printControls element.
Remember that this bookmarklet will only work if the structure of the page and the ID of the element remain consistent. If the website's HTML changes, you might need to update the bookmarklet accordingly.
------------------
You:
i love you!
------------------
ChatGPT:
I'm glad I could help you! If you have any more questions or need further assistance, feel free to ask. Enjoy your browsing!
------------------
 
跟住佢做左個bookmarklet for JS.
以後一鍵去floating element[/td][/tr][/table][/td][/tr][/table]
頁: [1]
查看完整版本: fwd from 朋友, gpt4 幫你寫 JS bookmarklet 做野